Created
August 17, 2016 21:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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