Skip to content

Instantly share code, notes, and snippets.

@kidhasmoxy
Created August 17, 2016 21:01
Show Gist options
  • Save kidhasmoxy/f25ba6a6ef13c547ce63837c9ae2aabd to your computer and use it in GitHub Desktop.
Save kidhasmoxy/f25ba6a6ef13c547ce63837c9ae2aabd to your computer and use it in GitHub Desktop.
ServiceNow REST Request helper for dealing with non-standard content types in a Scripted REST API
var RESTRequestHelper = Class.create();
RESTRequestHelper.prototype = {
initialize: function() {
},
type: 'RESTRequestHelper'
};
RESTRequestHelper.getRequestStreamString = function(requestBody){
var sb = ''+ GlideStringUtil.getStringFromStream(requestBody.dataStream);
return sb;
};
RESTRequestHelper.getJSONObjectfromBodyStream = function(requestBody){
var sb = GlideStringUtil.getStringFromStream(requestBody.dataStream);
var parsed = JSON.parse(sb);
gs.debug("RESTRequestHelper will return the following JSON object: {0}",JSON.stringify(parsed));
return parsed;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment