Scripted REST resource doesn't parse json when request contains Content-type headers with vendor tree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 12:32 PM
RFC 6838 - Media Type Specifications and Registration Procedures
According to RFC-6838 media type can include a vendor tree. A content-type of 'application/vnd.{vendor}+json' should be valid however ServiceNow is returning "message": "Invalid content-type. Supported request media types for this service are: [application/json, application/xml, text/xml]" when encountered.
IMHO, serviceNow should apply the json parser to it as the media type is valid according to the spec.
Because I'm working in a scoped app, I can't access the response body's datastream (streams are not allowed) and I can't control the content-type being sent in the request. Without moving to a scoped app, is there a way to access the request body when using a content type with a vendor tree? I'm using a scripted REST resource to catch a webhook from another service (helsinki). Is there better way to approach this problem?
Thanks in advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 06:32 AM
If you are using a scripted REST service then you have the option to overwrite the accepted content-types, by default 'application/json,application/xml,text/xml' are accepted.
Check the 'Override default supported request formats' field shown below and enter the content types you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 08:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 08:36 AM
Can you get the data string and convert that to a JSON object?
var obj = JSON.parse(request.body.dataString);
return obj.some_value;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 08:40 AM
Sorry for the confusion, I mentioned the json in the text but the examples are trying to use the datastring.
{
"error": {
"detail": "",
"message": "com.glide.rest.domain.ServiceException: Server error: attempt to access operations that are not allowed when request content is not one of ServiceNow default content types"
},
"status": "failure"
}