REST API - Patch and PUT methods to update multiple incident tickets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 01:10 AM - edited ‎07-07-2023 01:12 AM
Hi All,
We're integrated two servicenow instances to create the incident tickets when ever an incident ticket is created in one instance we need to replicate the same in another instance.
And we have used REST API - POST method and it's working fine now.
But we want to update the incident when ever we update the incidents in one instance need to set the same field info in another instance.
We're trying to use REST API "PUT / Patch" methods, but it's not updating in another instance.
Note: It's working properly only when we give the ticket sys_id in endpoint.
But we have more than one incident tickets and we need to update only mirror incident ticket in another instance.
And sys_id are same in both the tickets on instance level.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 02:43 AM
Hi Ankur,
Many thanks for the update.
After giving below URL as endpoint, we're getting attached error.
endpoint: https://devXXXXX.service-now.com/api/now/table/incident/ + current.sys_id
Could you pls help us here.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 02:49 AM
got it
when you are hitting target instance then are you storing the target incident record sysId in some field on current incident i.e. are you storing it in correlation_id field
Unless you know the target record sysId you cannot update
And sys_id are same in both the tickets on instance level. -> this is wrong the sysIds would be different. Did you check both the incidents?
try to update as this if you are using correlation_id field
r.setEndpoint('https://dev75096.service-now.com/api/now/table/incident/' + current.correlation_id);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 02:56 AM
Hi Ankur,
I have checked the created incidents sys_id'S on both the instances level and having same sys_id'S.
Do we need to make any changes on BR script level.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 03:05 AM
if that's the case then the endpoint should be a valid one
I think you didn't copy the exact script I shared. you are using an extra quote it seems
share your updated script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2023 03:31 AM
Hi Ankur,
Thanks for your valuable time.
PLease find the below script: BR -> After -> Update
Note: Logs level we're getting as below:
Status of the update incident:405 |
And if we use patch method and clicks on test link, we're getting below error as well:
Advance thanks.