JS SDK createUsers() call fails "No record(s) detected in request"


#1

Hi there,

I am new to DreamFactory, and doing some initial investigation of the functionality. So far looks very impressive.

I was trying to create a new user using the JS SDK, based on the example .
I have authenticated and have the correct privileges, and can create users in the DSP User admin and Live SDK.

A code snippet is shown below, and I get the error response, “No record(s) detected in request”

I feel as though I am doing something stupid. The documentation is brief for the SDK, it just says body, so I am translating the required body from the Live SDK info. It works in the Live SDK but not in the JS SDK call?

Running a local version of 1.9

Thanks

Tim

var body = { "record": [
    {
      "id": 0,
      "email": newUsrEmail,
      "password": "",
      "first_name": newUsrFirstname,
      "last_name": newUsrSurname,
      "display_name": "",
      "phone": newUsrPhone,
      "is_active": false,
      "is_sys_admin": false,
      "role_id": newUsrRole
    }
  ]
};
/* newUsrLang
   newUsrTz*/
window.df.apis.system.createUsers(body, function (response) {
  //Do something with the data;
  document.getElementById("newUsrResults").innerHTML = JSON.stringify(response);

}, function(response) {
  document.getElementById("newUsrResults").innerHTML = window.app.getErrorString(response);
});

#2

I found the solution to my own problem.

I had constructed the record correctly but needed to put the Record data within a { body : … }

var RecordBody = {"record":[{"id":0,"email":newUsrEmail,"first_name":newUsrFirstname,"last_name":newUsrSurname,"display_name":"TAT","phone":newUsrPhone,"is_active":false,"is_sys_admin": false,"role_id":newUsrRole}]};
window.df.apis.system.createUsers({body: body}, function (response) {