Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

PUT API giving error message

tsoct
Tera Guru

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:

tsoct_0-1676309655476.png

PUT 

tsoct_3-1676310146875.png

 

tsoct_2-1676309850827.png

 

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);

 

 

 

 

1 ACCEPTED SOLUTION

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. 

View solution in original post

10 REPLIES 10

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.