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.

Issue with Table REST API Post request

Cam14
Tera Contributor

I have a table that should hold JSON in a field, u_body. When I send a post request to the table API with valid JSON which looks something like

 

{"u_body": [{"DATA": "123","SERIAL_ID":"ABC123"...}]}

 

I get a 201 success request, but the string in u_body and the post response string for u_body doesn't look like the JSON I sent. It ends up being like

 

"{[DATA=1234,SERIAL_ID=ABC123...]}"

 

Has anyone experienced this? If so, what is the fix to preserve the original JSON so I can actually use it and don't get stuck with the incorrectly formatted string?

3 REPLIES 3

priyatam_pvp
Tera Guru

ServiceNow automatically converts JSON objects into JavaScript objects (GlideElements) when storing them in a table. It replaces : with = and removes quotes.

Try this 

{
"u_body": "{\"DATA\": \"123\",\"SERIAL_ID\":\"ABC123\"}"
}

Please Mark it helpful
Regards
Priyatam

Chaitanya ILCR
Mega Patron

Hi @Cam14 ,

try sending the data in this format

{"origins":"[{\"Critical Update Instruction Flow.2bf457f553143110a8edddeeff7b12a9\":\"2bf457f553143110a8edddeeff7b12a9\",\"Critical Update Instruction Flow.a67a673d53543110a8edddeeff7b12a8\":\"a67a673d53543110a8edddeeff7b12a8\",\"Critical Update Instruction Flow\":\"f8e2d4361172021008ddf292ecbfee14\",\"Critical Update Instruction Flow.7dea6e7d53503110a8edddeeff7b12ee\":\"7dea6e7d53503110a8edddeeff7b12ee\"},{\"Critical Update Instruction Flow.2bf457f553143110a8edddeeff7b12a9\":\"2bf457f553143110a8edddeeff7b12a9\",\"Critical Update Instruction Flow.a67a673d53543110a8edddeeff7b12a8\":\"a67a673d53543110a8edddeeff7b12a8\",\"Critical Update Instruction Flow\":\"f8e2d4361172021008ddf292ecbfee14\",\"Critical Update Instruction Flow.7dea6e7d53503110a8edddeeff7b12ee\":\"7dea6e7d53503110a8edddeeff7b12ee\"}]"}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Thanks. That works, but I just need regular JSON.