REST POST that chooses a user from user reference field isn't populating

ctsmith
Mega Sage

I have a POST function that works on every field I've tried except for choosing a user from user reference field.

The body is:

{"name":"Chris Test","memory":"32","managed_by":"xxx4fxc30a0a3c53217xxxxeb21742c5"}

It will create a new record and populate the new fields in the body except for managed_by.   I tried sys_id based on the REST API Explorer, and it worked with my admin account internally, worked with admin account externally, but not with the system user I created.   I added full admin rights to the system user to see, and that still didn't work.

Any ideas of why this isn't working?


Thanks!

1 ACCEPTED SOLUTION

So...   I ended up having to put an ACL on a seemingly unrelated field.   And, I had to clear out the session cookies in Postman, then the managed_by started returning.     Very odd it was just an issue on this one field, but solved.


View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Chris,



So you want to insert a record in the table and want to populate user with that sys_id in that field.


What error you are getting?


Is the record getting created with empty user i.e. empty managed_by



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Correct, on all accounts.   Record is created, fields populated as they should be, except for Managed by remains blank:



find_real_file.png



I've tried sys_id and userID as well. Neither work.   I'd prefer to use userID, but API Explorer builds using sys_id since it's a reference field to user table.



Best,


Chris


Hi Chris,



The system which is consuming the servicenow endpoint how they will know the sys_id of the record?



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Right.   They probably won't know the user's sys_id.   But, I just wanted to make it work first in testing it out before I figure out how to let them use userID.   I was just going by the REST API Explorer with the example it gives is the sys_id:



find_real_file.png



Thanks!


Chris