ServiceNow - SAP Integration

Vaibhav Sharma1
Tera Contributor

Hi All,

I am currently working on a ServiceNow - SAP integration with below structure:

- Need to pull data from SAP to core_company table in ServiceNow

- Oauth configurations are already done and tested for this

- I need to create REST message with GET method and trigger it by a background script to test that data is coming from SAP to ServiceNow

 

Can anyone assist what exactly I need to do for this. New to integrations so not much sure of it

5 REPLIES 5

Amit Pandey
Kilo Sage

Hi @Vaibhav Sharma1 

 

You need to configure a REST Message with SAP endpoint, GET Method, and Authentication type and profile. In the HTTP Header section, you can configure it something like this based on your authentication type-

AmitPandey_0-1713416839752.png

 

Then you can trigger it with the help of Business Rule to fetch the data in the core_company table.

Outline of BR-

 

var restMessage = new sn_ws.RESTMessageV2('SAP Data Pull', 'GET'); //Assuming the name  of REST message & HTTP Method
restMessage.setRequestHeader('Content-Type', 'application/json'); // Set additional request parameters if required (headers, query parameters, etc.)
var response = restMessage.execute();
var responseBody = response.getBody();    
gs.info('Response from SAP: ' + responseBody); // Process the response body as needed

 

Please mark my answer helpful and correct.

 

Regards,

Amit

 

Hi @Amit Pandey 

 

The above BR is working when I manually get the access_token. Can you help me with the steps of token generation from BR? I am using client credential as grant type. 

Please help. 

Hi @testp21 

 

Please refer to my reply in this thread-

 

https://www.servicenow.com/community/hrsd-forum/i-have-to-do-integration-from-servicenow-to-third-pa...

 

You can test it in background script first. Hope it helps.

 

Please mark my answer helpful and correct.

 

Regards,

Amit

yad_achyut
Giga Guru

@Vaibhav Sharma1 : Hello Vaibhav there is no need of triggering the GET method from the background script you can make use of OOB Test Functionality provided by ServiceNow follow the following Steps to test the API
1. Create a REST Message record (Mention your endpoint of SAP there just make sure of the accessibility of  the Rest Message while creation under the dropdown of "Accessible From" on the right side of the form,.

Screenshot 2024-04-18 at 10.30.42 AM.png
Note : Once you create a Rest Message you will get a default get Method  created by servicenow you can use that for testing else you can create a new by following the below steps.

2. Create a new Get Method by clicking on the "New" Button
Screenshot 2024-04-18 at 10.39.34 AM.png


3. Fill all the required details for the creating the "Get" Method.
Screenshot 2024-04-18 at 10.38.16 AM.png

 

4. Configure your OAuth Profile to the Method or Configure it to the REST Message and use option "Inherit from Parent"
Screenshot 2024-04-18 at 10.44.38 AM.png

 

5. Configure HTTP Headers  & HTTP Query Parameters* (if required) under HTTP Request for the created get Method
Screenshot 2024-04-18 at 10.47.44 AM.png

 

6. Do the Variable Substitution (if required) by clicking on the New button.Screenshot 2024-04-18 at 10.52.42 AM.png


7. Click on Get OAuth Token  under the Related Links.
Screenshot 2024-04-18 at 10.54.38 AM.png
once you received the Token successfully.

8. Click on Test under the Related list 
Screenshot 2024-04-18 at 10.59.02 AM.png

Once you click on Test you will be able to get the Response from SAP as per the requested API

Thanks & Regards
Achyut