Request JSON object is null

I am trying to do insert with the third party rest api call.
I set Contracts json like this
JSON
{
"title": "Create Ticket",
"description": "Input items to create a ticket",
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"required": [
"employee_username",
"request_detail"
],
"properties": {
"employee_username": {
"description": "employee username",
"type": "string"
},
"request_detail": {
"description": "short description",
"type": "string"
}
},
"additionalProperties": true
}
Output
JSON
{
"type": "object",
"properties": {
"number": {
"description": "incident number from serviceNow",
"type": "string"
}
},
"additionalProperties": true
}

Configuration:
Request : Post
JSON
{
"requestUrlTemplate": "https://myinstance.service-now.com/incident.do?JSONv2&sysparm_action=insert",
"requestType": "POST",
"headers": {
"Content-Type": "application/json",
"Content-Transfer-Encoding": "buffered"
},
"requestTemplate": ""{"sysparm_action":"insert","caller_id":"{input.employee_username}\",\"short_description\":\"{input.request_detail}","category":"NETWORK","subcategory":"WHOLE SITE"}""
}
Response
{
"translationMap": {
"numberValue": "$.records[0].number"
},
"translationMapDefaults": {
"numberValue": ""INC000001""
},
"successTemplate": "{\r\n \t"number":$numberValue\r\n }"
}

When execute, I got the following error
{
"error": "Request JSON object for insert cannot be null."
}
It looks like the parser failed to convert Request JSON string to Request JSON Object. Any idea?

Hi Julie,

Take a look at the results of the "resolve body template" step. That should show if the body is ending up the way you would expect it to.

--Jason

It looks like this
""{"sysparm_action":"insert","caller_id":"123456","short_description":"test","category":"NETWORK","subcategory":"WHOLE SITE"}""

I think, it should be object here, but it is string. The original results are with "\".

Please export your action, redact anything sensitive in it, and post it to this thread.

Your request body template looks like it has an extra quote at the start and end, but but this forum will hide escape characters, making it hard to figure that out.

--Jason

A couple of things from looking at service now documentation:
https://docs.servicenow.com/bundle/orlando-application-development/page/integrate/inbound-other-web-services/concept/c_DataModificationAPI.html

It looks like you could remove the sysparm_action from the body if you want.

The examples all seem to include a priority, I don't know if that is actually required but got my attention.

Yes, Jason. I removed the extra quote from the start and end. It works fine now. Thanks a lot!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.