0

I am using Services 7.3 and REST server to add new authenticated users via POST. All is working well except for the "customer" user field (boolean) that isn't required (and is actually hidden on the User Registration form). This is what my Json looks like:

"field_customer":{   
   "und":"1" 
}

But the field value of the newly created user remains unchecked. As soon as I turn the field into required, this same exact code works and the field value on the new user becomes checked. I've tested it with another test field and the result was the same - if the field isn't required it won't save the data to the new user.

I've tried to look through Services code to see why this would happen without success. There is a similar issue here: how can I update user global fields in drupal services? but it was never answered and it also deals with updating existing users via PUT.

Has anyone else had problems with non-required items on user creation via REST? Am I doing something wrong here which I have overlooked, or is this a bug?

  • Try JSON like this: field_customer: { und: [ { value: "1" } ] }, as you've noticed the Services module is very picky (depends on the field form widget always, and results may vary when POST vs. PUT) – tyler.frankenstein Jun 23 '16 at 14:18
  • Thanks so much @tyler.frankenstein tried but didn't work :( Yes Services is certainly picky sometimes! I tried field_customer:{und:{0:{value:"1"}}} as well and a few other combinations but no luck either. The thing that gets me is how the code on my op works when the field is required but doesn't work when it isn't required... – longboardnode Jun 24 '16 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.