Problem Creating user via REST API

Problem Creating user via REST API

by Valentin Vollmer -
Number of replies: 1

Hi,

I am trying to create users and enroll them via the REST API - and it is not working for me.

Since I am using Filemaker (desktop database) to access the API I am restricted to serialized POST calls. I have a token and some calls are successful, I get a valid XML response and can parse it 

...?webservice/rest/server.php?wsfunction=core_enrol_get_enrolled_users&courseid=81&wstoken=XXXXXXXXX


for example returns what I need. So that means the user is created, I can communicate with the server etc.


The following call however returns I error I can not figure out:

...?wsfunction=core_user_create_users&users[0][username]=FakeName&users[0][password]=FakePW&users[0][firstname]=NAME&users[0][lastname]=LastName&users[0][email]=fakeName@gmail.com &wstoken=XXXXX

Returns:

<?xml version="1.0" encoding="UTF-8" ?>

<EXCEPTION class="invalid_parameter_exception">

<ERRORCODE>invalidparameter</ERRORCODE>

<MESSAGE>Invalid parameter value detected</MESSAGE>

</EXCEPTION>


I don't know what I am doing wrong here, would very much appreciate any kind of help!

I checked the call with requestBin to see what actually gets send, and as far as I can tell it looks good:

FORM/POST PARAMETERS

users[0][email]: FakeName@gmail.com 

wstoken: 4XXXXX

users[0][password]: FakePW

users[0][firstname]: Name

wsfunction: core_user_create_users

users[0][lastname]: LastName

users[0][username]: FakeName

HEADERS

Accept-Encoding: deflate, gzip

Content-Length: 219

Via: 1.1 vegur

Accept: */*

User-Agent: FileMaker/14.0

X-Request-Id: c7145abf-d68e-4834-8cf8-05e13286022e

Connect-Time: 2

Host: requestb.in

Total-Route-Time: 0

Connection: close

Content-Type: application/x-www-form-urlencoded

RAW BODY
wsfunction=core_user_create_users&users[0][username]=FakeName&users[0][password]=FakePW&users[0][firstname]=Name&users[0][lastname]=LastName&users[0][email]=FakeName@gmail.com%20&wstoken=4ee08a7ac8f4f6ebb2c86edfff0d36e5
Thanks everybody!
Average of ratings: -
In reply to Valentin Vollmer

Re: Problem Creating user via REST API

by Valentin Vollmer -

I fixed the problem and just want to share how in case somebody else might find it helpful.


The first and most important step was to increase the level of debugging information the server returned.


in Site Administration - Development set "Debug Messages" to "Developer...". After doing that I actually saw what the invalid parameter was. I did not pass a language parameter since it says it will default to "en_us" anyway. Well, the problem is that the server only supports "en" apparently. Our site is hosted by Mrooms.net, not sure if that is something specific to them. After specifically passed the language parameter as "en" I got it to work.

Average of ratings: Useful (3)