Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

API Post (Create) Not Returning a response in body

twenger26
Giga Contributor

I am attempting to use the SN Rest API to create users.  Every time I do a POST (create) with the user account I created I get a response of 201 which is good since it does create the user (sys_user), but the body of the response is blank...

If I use my local account (which has admin role) and do the same thing I do get a body response with fields from that new record.  It appears I have some sort of permission issue.

The weird thing is I can do a get or any other type of API query with that account and all of the field values are returned fine.   It's something about doing the Create which is returning a blank response.  But the record is created so I'm fairly confused.

I don't want to give this new account an "admin" role.  I only want it to be able to create/edit/read  the user, department, and location tables.  So far I've given it these roles with no success on getting a body response:

 

find_real_file.png

6 REPLIES 6

If the issue is reagarding the authorization then we would get a different response code

George Snyder
Tera Contributor

In my case I was seeing the exact same behavior when I sent "sys_id" with a null value in the request (easy to do if you, like me, are using a library to convert an object into JSON which is described by a class - depending on library options, it may consider "null" in the "sys_id" field to be signficant and worth including in the JSON document).  If I just don't include the "sys_id" in the JSON document that is sent at all, it does include the created record in the response.

 

Payload sent that didn't work:

 

{"short_description": "test", "description": "test", "sys_id": null}

 

Payload sent that did work:

 

{"short_description": "test", "description": "test"}