JSON data modification API

Caro92
Tera Contributor

Hey guys,

 

I want to modify a value in a record via JSON data modification API. I used the following link as shown in the product documentation (https://docs.servicenow.com/en-US/bundle/vancouver-api-reference/page/integrate/inbound-other-web-se...) :

https://myinstance.service-now.com/sc_request.do?JSONv2&sysparm_query=description=paris&sysparm_acti...

I replaced myinstance.service-now.com with my instance URL. The expected result: Modification of the description field to the value 'test'. 

But the result I received is: {"reason":null,"error":"Invalid sysparm_action: update:{\"description\":\"test\"}"}

When I remove the body and enter the following URL: https://dev112435.service-now.com/sc_request.do?JSONv2&sysparm_query=description=paris&sysparm_actio... I received the following error message: {"reason":null,"error":"json object is null"}

 

How should the body look like to get the expected result?

 

Thanks for your help guys

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Caro92 

you need to pass the json request body since it's POST method

This worked for me. Ensure the user you are using to test has valid write access to the table and field

the json key should be the field name which you want to update

1) Method - POST
2) Application type - application/json

Request

AnkurBawiskar_0-1695206268490.png

 

Output: the field got updated with value 10

AnkurBawiskar_1-1695206298393.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Caro92 

you need to pass the json request body since it's POST method

This worked for me. Ensure the user you are using to test has valid write access to the table and field

the json key should be the field name which you want to update

1) Method - POST
2) Application type - application/json

Request

AnkurBawiskar_0-1695206268490.png

 

Output: the field got updated with value 10

AnkurBawiskar_1-1695206298393.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hey Ankur, 

 

I tried to execute the script with the same tool and got an 401 (Unauthorized) error message, even though I'm logged in as system administrator. 

 

Do you know whats the issue here?

@Caro92 

401 means incorrect username and password.

Please ensure you give correct credentials and that user has write access to record and field

I believe I have answered your query as I shared how the request should look like and the working output.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

And thanks for your support.