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

REST API

surya123
Mega Guru

Hi All,

We need to send the update to the third party system when a record is updated in Servicenow.

I created a PUT method. But I see a http status as 204 instead of 200.Becuase of this i asssume i see a blank response body. How can i get it as 200?

1 ACCEPTED SOLUTION

Dave Smith1
ServiceNow Employee
ServiceNow Employee

surya soni wrote:



Hi Dave


Is it fine to have the status as 204 ? But if the response body is not having any data,, How will it update the third party system with the data change in the SNOW?


The response is the third party letting you know everything's okay - it should have performed the update/action as you requested.   Essentially, you've put a letter into the postbox successfully - the postbox hasn't printed off a receipt to show you it's been received.


whn i copy the script from the PUT method and use it in BR, i see a status code as 404 instead of 204.


404 is "page not found".   So presumably there's some error.   Did you check the weblogs on the third party to see what caused it?


Is there something I need to do, so I can update the 3rd party system when any value changes in SNOW?


You keep mentioning data you're sending to the third party... are you yet to check this third party to see if it's worked at all?   You're posting letters, asking the postbox why the recipient hasn't received them... why not ask the recipient directly?


I am getting a GET response from 3rd party system which I am using from creating rec in SNOW. Nw when those recods are updated I want to update the record in 3rd party system aswell.


Which presumably is the purpose of your exercise here.   But you don't seem to be checking the 3rd party for success at all.   As I mentioned above:


        If you need 200, you'll need to configure the receiving API to return something.


- meaning you'll need to get the API documentation for the third party and work out how it can return a response indicating success/failure.


View solution in original post

16 REPLIES 16

Hi Surya,



I assume here that 3rd party is consuming your api and when they send a request you need to send a response saying that update successful or some error.


So the code you shared is not something coded in Servicenow.



The code you shared is I think how 3rd party is consuming your endpoint. I want to check the code which you have written in your servicenow scripted rest api.


Hope you understood now.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi ANkur,


This is what i hav done in snow.


Can you please help what i should be doing next?



I have added a Endpoint . I have added the HTTP headers.


I have added the Content.



I didnot do anything in Scripted RST API.


Was i supposed to be doing something there?


Hi Surya,



So you are consuming the endpoint of 3rd party and sending some request but not getting valid response from them.


if so then 3rd party has to configure the response and send you status message i.e. success or failure.



Regards


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,


We are getting a response from 3rdparty. We are creating records in snow,


When a record is updated in servicenw, we wud send them an response so that the chnage in record gets synced into theirs.


so, i wrote that PUT method and also a BR. But for BR i see 404 and for PUT 204.


Is there anything i should be doing?


Any reason why would the Br show as 404 as HTTp status



I guess i got the logic. We are building the JSON as they would receive it. They receive it correctly but they need to configure the response so we get something back. Till that it will be blank.