- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 09:43 AM - edited ‎02-13-2023 10:34 PM
Hello all,
I created a REST Message to create and update the record of SN instance1 to SN instance2.
Information I am storing in instance2 including instance1.table.record.sys_id and I am attempting to Update the record in instance2 based on sys_id as a parameter.
My POST is working fine but PUT is giving me an error msg: {"error":{"message":"Method not Supported","detail":"PUT method not supported for API"},"status":"failure"}
Could you help to advise what could be the mistake?
*note:sys_id is stored as u_correlation_id in instance2
REST Message:
PUT
AFTER UPDATE business rule
(function executeRule(current, previous /*null when async*/ ) {
var body = {
"u_organization": gs.getProperty('instance_name'),
"u_name": current.name.toString(),
};
try {
var r = new sn_ws.RESTMessageV2('my Integration', 'Default PUT');
r.setStringParameterNoEscape('u_correlationid',current.getUniqueValue());
r.setRequestBody(JSON.stringify(body));
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2023 05:53 AM
Thank you Kirby. I need the sys_id to be dynamic and I've managed to achieve what I wanted with staging table and transform map.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 09:49 AM - edited ‎02-13-2023 10:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 11:23 PM
Please use Patch instead of Put
check the explanation here
How to avoid the 405 error { "message": "Method not allowed" } in Rest Message in Put method
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 11:30 PM
Hi @tsoct ,
You should be passing the sys_id/correlation id directly after slash in your url parameter. Something like this, u_license/3232323.
I was able to replicate the issue in my testing.
Here's a correct URL parameter:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2023 11:35 PM
Hi Kirby,
This is the error message i got when trying
I have also updated the BR in SNinstance2 to dynamically pass the record sysid to endpoint. But still getting the same error
var u_correlationid = current.getUniqueValue();
try {
var r = new sn_ws.RESTMessageV2('Subscription Integration', 'Default PUT');
r.setStringParameterNoEscape('u_correlationid', current.getUniqueValue());
r.setEndpoint('https://xxxxx.service-now.com/api/now/table/u_license?sysparm_query=u_correlationid='+u_correlationid);
r.setRequestBody(JSON.stringify(body));