Set the status code when using a transform map through import?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 01:58 PM
Our requirement is to accept incidents from another system. To keep it simple I want to use the import interface, so I'm using a transform map to fill in the bits the calling system doesn't know about, like who should be assigned to the incident. That's working fine. However sometimes I want to reject the request, for example if the configuration item is unrecognized. In particular, I want to set the status code in that case. in other words I don't want to tell the caller they have to look at the response body to know whether their request was a success or not -- although they will be looking at the body to get the incident number, url and so on.
So among other things I scrolled down to the bottom of the map and added a Transform Script and set the When to trigger to onBefore, and put in something like
if(source.configuration_item.isnil()){
error = true;
error_message="no soup for you.";
}
And so on. But the status code is still 201 no matter what I do. My case is similar to what this user was asking:
Error message with a success http code
So is there a way to set the status code when using the import interface?
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 07:23 AM
So what I was asking here is, briefly, how do I make sure the status code is something in the 400 range if the client does a POST to a staging table that the target table will not accept. It seems most of the answer is to look at the Data Policies in place for the target table, and create a similar data policy for the staging table. So if the client posts something lacking a description value they get a 403 back from the staging table. It looks like that will meet the requirement.