The CreatorCon Call for Content is officially open! Get started here.

modify output from REST API - integration

sammarcow
Mega Expert

i need a simple integration to return fields with certain parameters on utilizing of Post.   I basically need to rename some of the fields on the response body.     Does ServiceNow have the ability to retrieve the results of a Post, utilize server side code and generate a new return body, or will I need to create a web service in order to handle the out-of-box return messages?   I am doing a custom integration for Slack if that matters.    

1 ACCEPTED SOLUTION

Scripted REST was introduced with the Geneva release, so this won't be an option for you then. Any chance you have a G upgrade on the horizon?



If not, this can also be accomplished with a custom Processor, but beware these are a bit trickier to work with. Here's a bare-bones tutorial to get you started:



http://wiki.servicenow.com/index.php?title=Tutorial_4_Creating_a_Custom_Processor


View solution in original post

7 REPLIES 7

@NeriusNow can the processor read Post properties or only query string?


I've written a blog series on custom building a REST API (only using GET), partly to be able to rename fields. Part 6 is on building a processor. And, yes, processors can do POST:



GQL (Glide Query Language) Part 6: The Processor



Part 4 describes the Script Include that fetches the data; if you want to keep it simple, this may be included in your processor:



GQL (Glide Query Language) Part 4: The Retriever



Good luck!



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

Winner of November 2016 Members' Choice Award


Also, if you're using JSON, you might want to make a note of the below:



g_processor.writeOutput("application/json", new global.JSON().encode(result));   // works in global & scoped


g_processor.writeJSON(result);   // works in scoped only