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.

Problem retrieving authentication profile: when calling oath2.0

mahima_chhajer
Tera Contributor

Hi All,
I have created one post method for the API

when trying to connect with postman or adding the content when I am using rest message its working also I am getting the Oath token
but when I created the business rule (when incident is inserted , BR should run and send the Body to 3rd party)

then I am getting the error : Problem retrieving authentication profile:
not sure where I am going wrong .


code I have written :

(function executeRule(current, previous /*null when async*/) {

gs.log("Mahima and gaurav");

var sm = new sn_ws.RESTMessageV2("test demo","demo method name");

 sm.setAuthenticationProfile('oauth2', 'profile name'); (oauth profile name)
 
 var body = {
                "id": "6a0b852e-656d-11e7-b02d-11172021-1",
                 "info": {
            "type": "Add",
            "publicationDate": "2021-12-01T09:03:01.574Z"
        },
                "data":
                {
                "description": current.incident.description.toString(),                
                "urgency": {
                    "id": current.incident.urgency.toString(),
                },
                "priority": {
                    "id": current.incident.priority.toString(),
                },
                "impact": {
                    "id": current.incident.impact.toString(),
                },
                "caller":{
                    "id": current.incident.caller.toString(),
                } ,      
                "actionInProgress": {
                    "description": current.incident.short_description.toString(),
                },
                "relatedService": {
                    "serviceSpecCharacteristic": [{
                        "value": current.incident.business_service.toString(),
                    }],
                }
            }
};

   sm.setRequestBody(body);
 
 sm.setRequestHeader("Accept","Application/json");
 sm.setRequestHeader("Content-Type","Application/json");
  sm.setRequestHeader("X-Origin-Caller","MyCSM NPD");
var response = sm.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log("body",responseBody);

gs.log("http status",httpStatus);


})(current, previous);



1 REPLY 1

Maik Skoddow
Tera Patron
Tera Patron

Hi @mahima_chhajer 

if you have a problem with the OAuth profile you should provide details about that configuration and not the code of your REST request!

Maik