ServiceNow - SAP Integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 09:45 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 10:11 PM
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-
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 11:06 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 11:09 PM
Hi @testp21
Please refer to my reply in this thread-
You can test it in background script first. Hope it helps.
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2024 10:32 PM
@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,.
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
3. Fill all the required details for the creating the "Get" Method.
4. Configure your OAuth Profile to the Method or Configure it to the REST Message and use option "Inherit from Parent"
5. Configure HTTP Headers & HTTP Query Parameters* (if required) under HTTP Request for the created get Method
6. Do the Variable Substitution (if required) by clicking on the New button.
7. Click on Get OAuth Token under the Related Links.
once you received the Token successfully.
8. Click on Test under the Related list
Once you click on Test you will be able to get the Response from SAP as per the requested API
Thanks & Regards
Achyut