Rest Variable substitutions

tsoct
Tera Guru

I need to send two dynamic parameters to the endpoint for querying. I confirmed that the token works properly. However, it returns no value, and when debugging, the endpoint remained unchanged without a value passed. 

 

 

 

getACTIVITY2: function() {
        try {
            var r = new sn_ws.RESTMessageV2('CPNYCostCenter', 'Get ACTIVITY');
            r.setStringParameterNoEscape('p_fund', 'AF'); //Hardcode for now to debug
            r.setStringParameterNoEscape('p_org', 'CSIPM'); //Hardcode for now to debug
			r.setRequestHeader('Authorization', 'Bearer ' + this.token);

            var response2 = r.execute();
            var responseBody2 = response2.getBody();
            var httpStatus2 = response2.getStatusCode();
			gs.info("The Activity: " + responseBody2); //return empty
                        gs.info("Endpoint: " + r.getEndpoint();) // return https:url.com//ServiceNow/getActivityList?p_org=${p_org}&p_fund=${p_fund} //Variable value did not pass into the endpoint
        } catch (ex) {
            var message = ex.message;
        }
    },

 

 

 

tsoct_0-1715755006844.png

 

1 ACCEPTED SOLUTION

kente
Tera Guru

You are posting the query parameters twice

kente_0-1715767052022.png


If you do that you will get them twice

kente_1-1715767100666.png

If using the HTTP Query Parameters you should not add anything in the path. It will add "?" as well as the parameters you hav added

View solution in original post

9 REPLIES 9

try the below 

content-type = application/xml.

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Failed too

with code: 415: no thrown error

 

These are the parameters

dgarad_0-1715766049334.png

2nd parameters change like as Bearer ${Token}

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

kente
Tera Guru

You are posting the query parameters twice

kente_0-1715767052022.png


If you do that you will get them twice

kente_1-1715767100666.png

If using the HTTP Query Parameters you should not add anything in the path. It will add "?" as well as the parameters you hav added

Spot on! Thank you!