API call returning "not valid json" error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 03:34 PM
Please bear with me; I am a Jira admin and don't know much about ServiceNow. I've been asked to use Jira's automation rules to make a SNOW API call to add a work note to a SNOW ticket that's linked to a Jira ticket when the Jira ticket's Description field (the body of the ticket) is updated.
I do have other integrations that work correctly (i.e. adding a work note when the linked Jira ticket is marked as Closed). But the request for this one was to include the text from the ticket body in the work note.
This is what my api call configuration looks like:
Here's the error I'm getting back from SNOW:
Here's the actual payload being sent; the contents are 100% valid json.
Does anyone have any ideas what ServiceNow doesn't like about this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 05:01 PM
Hi, testing this quickly (based on screenshots) with Postman, I do not receive an error using table API and PUT to update an incident in a PDI and this is an accepted format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 10:11 AM
Thank you for the response, and sorry for the delay - I've been out of office.
I don't have control over the text that's being sent; it's pulling info in from the Comments field on whatever Jira ticket triggered the automation. Here's an example of the exact payload that also caused the same error:
{'work_notes':'"09-02-2022 12:34:58 - Guest (Additional comments)\nreply from: WP@x.com\n\nHey Roger,\n\nWe've escalated this to web maintenance for further review.\n\nJohn Doe\nSystems Specialist | Web Portal Applications Team\nService Desk\njohn.doe@x.com<john.doe@x.com>"'}
And the response payload:
{ "error": { "message": "Exception while reading request", "detail": "The payload is not valid JSON." }, "status": "failure" }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2022 03:41 PM
Hi, using a couple of online JSON validators to check your message, I get an invalid result.
https://jsonlint.com/
https://www.jsonschemavalidator.net/
I recommend that the next step would be to engage whoever is responsible for the JSON payload and have it reviewed\corrected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2022 06:36 PM
JSON mandates double quotes as property name and value delimiters. So those strings are not valid JSON. So no wonder you get errors.