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.

Succesfator rest api integration

SupriyaWaghmode
Kilo Sage
Kilo Sage

Hello Team ,

 I have written script to rest api call (get method) in scheduled job but no data inserted  in stagging table.

I retested rest message it shows as 200 success.

below is the snap shot of code

 

 

 var r = new sn_ws.RESTMessageV2('LR-Successfactor-Outbound-Integration', 'PerPerson'); // Call PerPerson Job
    var response = r.execute();
    var responseBody = response.getBody();
    gs.log("LR-Successfactor-responseBody"+responseBody );
    var httpStatus = response.getStatusCode();
    gs.log("SW-httpStatus1"+httpStatus);  --unable get this system log
    if (httpStatus == 200) {
        var jsonObj = gs.xmlToJSON(responseBody);

        var str = JSON.stringify(jsonObj);
        var jsonbody = JSON.parse(str);

        var perPersonal = new GlideRecord("sn_hr_core_lr_successfactors_data");
        for (i = 0; i < jsonbody.feed.entry.length; i++) {
            perPersonal.initialize();
            perPersonal.u_employee_number = jsonbody.feed.entry[i].content['m:properties']['d:personIdExternal'];
            perPersonal.insert();
        }
    }
2 REPLIES 2

Hugo Barros
Tera Contributor

Hey @SupriyaWaghmode, are you able to get the first log? the response body one

@Hugo Barros  yes, its xml version

 

But jsonbody getting only [object,object]

 

?xml version="1.0" encoding="utf-8" standalone="yes"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://api12preview.sapsf.eu/odata/v2/"><id>https://api12preview.sapsf.eu/odata/v2/PerPerson('451091')</id><title type="text"></title><updated>2024-02-09T07:14:36Z</updated><author><name></name></author><link rel="edit" title="PerPerson" href="PerPerson('451091')"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/personalInfoNav" type="application/atom+xml;type=feed" title="personalInfoNav" href="PerPerson('451091')/personalInfoNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/emergencyContactNav" type="application/atom+xml;type=feed" title="emergencyContactNav" href="PerPerson('451091')/emergencyContactNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/personEmpTerminationInfoNav" type="application/atom+xml;type=entry" title="personEmpTerminationInfoNav" href="PerPerson('451091')/personEmpTerminationInfoNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/customString5Nav" type="application/atom+xml;type=entry" title="customString5Nav" href="PerPerson('451091')/customString5Nav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/employmentNav" type="application/atom+xml;type=feed" title="employmentNav" href="PerPerson('451091')/employmentNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/countryOfBirthNav" type="application/atom+xml;type=entry" title="countryOfBirthNav" href="PerPerson('451091')/countryOfBirthNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/homeAddressNavDEFLT" type="application/atom+xml;type=feed" title="homeAddressNavDEFLT" href="PerPerson('451091')/homeAddressNavDEFLT"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/customString4Nav" type="application/atom+xml;type=entry" title="customString4Nav" href="PerPerson('451091')/customString4Nav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/phoneNav" type="application/atom+xml;type=feed" title="phoneNav" href="PerPerson('451091')/phoneNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/personRerlationshipNav" type="application/atom+xml;type=feed" title="personRerlationshipNav" href="PerPerson('451091')/personRerlationshipNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nationalIdNav" type="application/atom+xml;type=feed" title="nationalIdNav" href="PerPerson('451091')/nationalIdNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/userAccountNav" type="application/atom+xml;type=entry" title="userAccountNav" href="PerPerson('451091')/userAccountNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/personTypeUsageNav" type="application/atom+xml;type=entry" title="personTypeUsageNav" href="PerPerson('451091')/personTypeUsageNav"></link><link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/emailNav" type="application/atom+xml;type=feed" title="emailNav" href="PerPerson('451091')/emailNav"></link><category term="SFOData.PerPerson" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category><content type="application/xml"><m:properties><d:personIdExternal>451091</d:personIdExternal><d:lastModifiedDateTime m:type="Edm.DateTimeOffset">2017-01-27T16:26:35Z</d:lastModifiedDateTime><d:createdDateTime m:type="Edm.DateTimeOffset">2017-01-26T11:45:37Z</d:createdDateTime><d:createdOn m:type="Edm.DateTime">2017-01-26T11:45:37</d:createdOn><d:countryOfBirth m:null="true"></d:countryOfBirth><d:placeOfBirth m:null="true"></d:placeOfBirth><d:lastModifiedBy>CAP_001</d:lastModifiedBy><d:customString5 m:null="true"></d:customString5><d:customString4 m:null="true"></d:customString4><d:customString3 m:null="true"></d:customString3><d:dateOfBirth m:type="Edm.DateTime">1981-03-24T00:00:00</d:dateOfBirth><d:customString2>BKLCCY</d:customString2><d:perPersonUuid>CEB6458102914912BA3BDA966306D77C</d:perPersonUuid><d:customString6>Chris.Cantwell@lr.org</d:customString6><d:lastModifiedOn m:type="Edm.DateTime">2017-01-27T16:26:35</d:lastModifiedOn><d:createdBy>430019</d:createdBy><d:personId m:type="Edm.Int64">24454</d:personId></m:properties></content></entry>