Working on Linkedin Integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 08:29 PM
I'm working on linking LinkedIn to my PDI for a project. I did it before but lost my PDI and was looking into the API documentation on the LinkedIn developer site but it looks like some of them no longer work. I also looked at older posts about it being done but they are outdated info. All the OAuth scopes are set based on the documentation but still no luck.
My Default GET keeps getting an error code even though the Get OAuth Token successfully works to connect.
What am I missing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2024 11:07 PM
Hi,
Can you help me with the grant_type, you are using? I would encourage you to use client credentials.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 02:32 PM
The grant type is Authorization code. It's worked this way in the past just trying to figure out what could be the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2024 09:38 PM
Hi @UnoZ06
In case of Authorization Code, you would require manual intervention after some days. Client credentials work seamlessly. Sharing you a sample background script, hope it helps-
try {
var client_id = 'Enter your client id';
var client_secret = 'Enter your client secret';
var grant_type = 'client_credentials';
var token_endpoint = 'https://example.com/services/oauth2/token';
var token_grant_url = token_endpoint + "?grant_type=" + grant_type + "&client_id=" + client_id + "&client_secret=" + client_secret;
var token_request = new sn_ws.RESTMessageV2();
token_request.setEndpoint(token_grant_url);
token_request.setHttpMethod("post");
var token_response = token_request.execute();
var response_body = token_response.getBody();
var response_obj = JSON.parse(response_body);
var access_token = response_obj.access_token;
gs.info('Token request response: ' + response_body);
gs.info('Access token: ' + access_token);
// Use the access token to make API calls
var api_request = new sn_ws.RESTMessageV2();
api_request.setEndpoint('https://example.com/services/data/v58.0/sobjects/Ticket__c');
api_request.setHttpMethod('post');
api_request.setRequestHeader('Authorization', 'Bearer ' + access_token);
api_request.setRequestHeader('Accept', 'application/json');
api_request.setRequestHeader('Content-Type', 'application/json');
var restObj = {
"ServiceNow_SysID__c": current.sys_id + '',
"Category__c": current.category + '',
"Subcategory__c": current.subcategory + '',
"Number__c": current.number + '',
"Opened_by__c": current.opened_by.name + '',
"State__c": current.state.getDisplayValue() + '',
"Assigned_to__c": current.assigned_to.name + '',
"Channel__c": current.contact_type.getDisplayValue() + '',
"Short_Description__c": current.short_description.toString().replace(/\v|\r|\0/g, "") + '',
"Description__c": current.description.toString().replace(/\v|\r|\0/g, "") + '',
"Name": current.number + ''
};
var restStr = JSON.stringify(restObj);
api_request.setRequestBody(restStr);
gs.info('API Request Endpoint: ' + api_request.getEndpoint());
gs.info('API Request Headers: ' + api_request.getRequestHeaders());
var api_response = api_request.execute();
var api_response_body = api_response.getBody();
gs.info('API Response Object: ' + api_response);
gs.info('API Response Body: ' + api_response_body);
gs.info(current.number + "\nSalesforce Case Create : HTTP Status : " + api_response.getStatusCode() + "\nRequest Body : " + api_request.getRequestBody() + "\nResponse Body : " + api_response_body);
} catch (error) {
gs.error('An error occurred: ' + error);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2024 02:09 AM
Hi Amit,
Can you explain where I can use this script? I try to implement LinkedIn and I'm stuck.