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.

Scripted Rest Service Supported request formats

dbaril
Tera Expert

I created a scripted rest service and set the Supported request formats to: application/json,application/xml,text/xml.  When I call the rest service with the body encoded as JSON and set the content-type header to application/json it works perfectly fine.  However If I format the body as XML with a header of application/xml I receive the following error message:

Status: 500 Internal Server Error

Message: com.glide.rest.util.RESTRuntimeException: Error Parsing input streamJSONObject[\"request\"] not found.

Is a scripted rest service not able to handle multiple formats?  Is there some other parameter I need to set?

Thanks,

Don

 

 

3 REPLIES 3

johndurden
Kilo Contributor

I realize this is 11 months old, but do you remember if you found a solution to this and what it was? This is literally the only result that shows up when I Google the error.

Actually, I found the problem shortly after posting my reply. I had a bad property name which didn't exist in the script for the web service.

 

// Bad version
gs.log(request.body.data);

// Fixed version
gs.log(request.body);

 

I don't know yet why request.body.data isn't there, but removing .data fixed my error.

Chris Nack
Tera Expert

It looks like the expected XML format must be:

<request>

   <entry>

   </entry>

    .

    .

    .

</request>

 

I think that error is indicating the parser couldn't find the <request> element in the body.