-3

I have a few required custom profile fields that are date pickers and checkboxes. and I'm not sure what type to put them as in the request the only example the documentation has is one with type string. I keep getting the response

{ "exception": "invalid_parameter_exception", "errorcode": "invalidparameter", "message": "Invalid parameter value detected", "debuginfo": "" }

this is my request below:

https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=fromapp&password=FakePass123&firstname=From&lastname=App&email=fake@mailinator.com&customprofilefields[0][type]=text&customprofilefields[0][name]=profile_field_Church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=date&customprofilefields[1][name]=profile_field_DOB&customprofilefields[1][value]=2014-06-19&customprofilefields[2][type]=checkbox&customprofilefields[2][name]=profile_field_Saved&customprofilefields[2][value]=1&customprofilefields[3][type]=text&customprofilefields[3][name]=profile_field_Sex&customprofilefields[3][value]=Male&customprofilefields[4][type]=text&customprofilefields[4][name]=profile_field_phone_no&customprofilefields[4][value]=1-868-479-8661&customprofilefields[5][type]=text&customprofilefields[5][name]=profile_field_Marital&customprofilefields[5][value]=Single

I'm not sure what I need to do to make this request work and the documentation doesn't give much insight or I just haven't found it

  • where is the api document? You can see the request in devtool, copy them as cUrl then import to postman. – lucas-nguyen-17 Sep 03 '21 at 00:41
  • What do you mean? I'm using a POST request in postman to try this. – Marc Hypolite Sep 04 '21 at 04:16
  • Did you follow Moodle api documentation? If not, you can try on browser and copy request as cUrl then import to postman. – lucas-nguyen-17 Sep 04 '21 at 09:51
  • Yes, I did follow the documentation. my problem is that I'm not sure what the list of types are that they are accepting for the customprofilefields I only saw string in the documentation I'm not sure what type to use for the fields that are dates or a checkbox – Marc Hypolite Sep 04 '21 at 17:07

1 Answers1

1

So after playing around with the request on postman what I discovered is that the only type you need to use is string. I also discovered that for date fields the value must be unixtime and for checkboxes the value must be either 0 or 1.

https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=formapp7&password=fakepassword&firstname=From7&lastname=App7&email=fake@mailinator.com&customprofilefields[0][type]=string&customprofilefields[0][name]=profile_field_church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=string&customprofilefields[1][name]=profile_field_saved&customprofilefields[1][value]=Yes&customprofilefields[2][type]=string&customprofilefields[2][name]=profile_field_man&customprofilefields[2][value]=0&customprofilefields[3][type]=string&customprofilefields[3][name]=profile_field_born&customprofilefields[3][value]=1630813061&customprofilefields[4][type]=string&customprofilefields[4][name]=profile_field_single&customprofilefields[4][value]=Single&customprofilefields[5][type]=string&customprofilefields[5][name]=profile_field_aboutyou&customprofilefields[5][value]=Well i am new

This is an example of how a request would look where profile_field_man is a checkbox and profile_field_born is a date field. something also worth noting is that 'born' is the short name of the profile field mentioned before and the words 'profile_field_' must be prepended to it. I hope this helps anyone trying to use auth_email_signup_user