user_fields are not stored correctly | Community
Skip to main content

user_fields are not stored correctly

  • November 10, 2021
  • 1 reply
  • 0 views

I'm using an admin token to set user_fields of an end user. 

Endpoint: /users/{id}

Method: PUT

Body:

user: {
  user_fields: {
    "push_notification_tokens": "XXX",
    },
  },
};
 
push_notification_tokens is a multiline text field.

Response is 200 OK, with user_fields showing the correct value. But when I retrieve the user using the API, or in the Zendesk interface, the property is not set.
 
Same issue for boolean fields, they result in a 200 OK with the correct value, but in reality the value does not change.
 
I had the same issue yesterday. Today it seemed to work, until now. Why is this happening?

1 reply

  • Author
  • November 11, 2021

So.. turns out I was mixing up user id's in my code.

I first fetched the end user using a token, then fetching the settings as an admin. Because end users cannot access their own settings unfortunately. But when fetching the settings, I did not pass the user id of the end user, thus defaulting to /me, which ended up changing the settings of the admin user instead of the end user.

Not sure why it looked like it worked in certain scenarios, probably due to differences between the local and live environment.