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.

Post multiple JSON objects.

Dan Belostotsk1
Mega Expert

Hi, i need to simulate posting multiple requests at one API call.

To test it i used cmdb_ci_aix_server WS as my endpoint, defined content-type = application/json, basic auth and tried to pass:

JSON object containing objects:
{{"name":"Name7"},{"name":"Name4"},{"name":"Name5"},{"name":"Name6"}}

Which throws the following error:

{

      "error": {

              "detail": "Cannod decode: java.io.StringReader@112f1d3",

              "message": "Exception while reading request"

      },

      "status": "failure"

}

Next i tried the same with array:
[{"name":"Name7"},{"name":"Name4"},{"name":"Name5"},{"name":"Name6"}]

This time only the only the first object was processed. All remainig objects ignored.


Is there a way to pass multiple objects at one call?

Thank you.

find_real_file.png

1 REPLY 1

andrewpilachows
Kilo Guru

The first example isn't going to work because it's not a valid JSON string.



The second example either still isn't constructed right, isn't using the insertMultiple API, or you need to construct your web service to iterate an array.


http://wiki.servicenow.com/index.php?title=JSONv2_Web_Service#Inserting_Multiple_Records&gsc.tab=0


http://wiki.servicenow.com/index.php?title=REST_API#gsc.tab=0