Integration amazon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2023 08:44 PM
Hi there!.... How to integrate servicenow with amazon , so that i can get amazon product details in servicenwo... Iam new to integration..Can anyone help on how the flow go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2023 01:09 PM
Hi Abhijith , Happy to help .
To integrate ServiceNow with Amazon, you can use Amazon's Product Advertising API (PA-API) to retrieve product details and then use ServiceNow's IntegrationHub to create a flow to consume the data.
Here are the high-level steps you need to follow:
- Create an Amazon developer account and register for PA-API credentials.
- Generate an access key and secret key for your ServiceNow instance.
- Create a ServiceNow REST message to call the Amazon PA-API.
- Create a ServiceNow script include to handle the response from the PA-API.
- Create a ServiceNow workflow that triggers the REST message and uses the script include to process the response.
- Create a ServiceNow catalog item that allows users to search for Amazon products and displays the details in ServiceNow.
Here's a detailed explanation of each step:
Create an Amazon developer account and register for PA-API credentials.
- Go to the Amazon Associates website (https://affiliate-program.amazon.com/)
- Click on "Join Now for Free" and follow the registration process.
- Once you're registered, go to the "Product Advertising API" page and click "Join."
- Follow the instructions to create an application and generate your credentials.
Generate an access key and secret key for your ServiceNow instance.
- Log in to your ServiceNow instance as an administrator.
- Go to "System OAuth > Application Registry."
- Create a new application and generate an access key and secret key.
Create a ServiceNow REST message to call the Amazon PA-API.
- Go to "System Web Services > Outbound > REST Messages."
- Create a new REST message and fill in the following fields:
- Name: Amazon Product API
- Endpoint: https://webservices.amazon.com/paapi5/searchitems
- HTTP Method: POST
- Authentication: OAuth 2.0
- Access Token URL: https://api.amazon.com/auth/o2/token
- Client ID: The access key you generated in Step 2
- Client Secret: The secret key you generated in Step 2
- Grant Type: Client Credentials
- Scope: leave this field blank
- Requested Token Lifespan: leave this field blank
- In the "HTTP Headers" section, add the following headers:
- Content-Type: application/json
- In the "HTTP Request Body" section, add the following JSON:
{
"PartnerType": "Associates",
"PartnerTag": "<your partner tag>",
"Keywords": "${searchTerm}",
"Marketplace": "www.amazon.com",
"Resources": [
"Images.Primary.Small",
"ItemInfo.Title",
"Offers.Listings.Price",
"Offers.Listings.Availability.Message",
"Offers.Listings.Condition",
"DetailPageURL"
],
"ItemCount": 1
}
Replace 'your partner tag' with your Amazon Associates Partner Tag.
Create a ServiceNow script include to handle the response from the PA-API.
- Go to "System Definition > Script Includes."
- Create a new script include and fill in the following fields:
- Name: AmazonProductResponseHandler
- Accessible from: All application scopes
- In the script body, add the following code:
var AmazonProductResponseHandler = Class.create();
AmazonProductResponseHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, {
processResponse: function(response) {
var responseBody = JSON.parse(response.getBody());
var product = responseBody.Items[0];
var title = product.ItemInfo.Title.DisplayValue;
Please mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal.
Thanks,
Punit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2023 04:41 AM - edited ‎03-30-2023 04:41 AM
@Punit S Hi sir ...as i didnt get proper api.. It is paused. But inspite of it another task.
So i got third party api, which has no authentication . The purpose is when i create new user data in sys_user table . Then the third party also should get new user created. In rest message post http method i created this.
and the after insert business rule used is.
But anyhow its not creating data in third party tool..can you help to achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2023 12:49 PM - edited ‎03-30-2023 12:51 PM
I would recommend you to get more familiarity with REST APIs . It's a best practice to have authentication and it does protect your data from being accessed or exposed.
To accomplish what you described , you can use ServiceNow's Outbound REST Message functionality to send data to the third party API whenever a new user is created in the sys_user table. Here are the high-level steps you can follow:
Define the REST endpoint and payload format of the third-party API. You'll need to know the URL of the endpoint, the HTTP method to use (e.g. POST), and the expected payload format (e.g. JSON).
Create a new Outbound REST Message in ServiceNow. This involves defining the URL of the third-party API endpoint, the HTTP method to use, and any headers or payload data that need to be sent.
Create a Business Rule in ServiceNow that triggers whenever a new user record is inserted into the sys_user table. The Business Rule should call the Outbound REST Message created in step 2 and pass it the user data to be sent to the third-party API.
Test the integration to ensure that new user data is being sent to the third-party API correctly.
Here are some additional details to keep in mind:
When creating the Outbound REST Message, be sure to define any required headers (such as Content-Type or Authorization) and include the payload format and data as needed.
In the Business Rule, you can access the user data using the GlideRecord API. For example, you could use var gr = new GlideRecord('sys_user'); gr.query(); while (gr.next()) { /* send user data to API */ } to loop through all user records and send each one to the third-party API.
Be sure to handle any errors or exceptions that may occur when sending data to the third-party API. You can use try/catch blocks or ServiceNow's built-in logging and error handling functionality to handle these cases.
It's a good practice to use asynchronous processing when calling external APIs from ServiceNow, especially if the API may take a long time to respond. You can use ServiceNow's async APIs (such as GlideAsyncCallback or GlideScriptable) to handle this.
Please ensure to mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal.
Thanks,
Punit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2023 08:24 PM
@Punit S Hi, In log its showing this!