CORS error occuring after accessing linkedin share api through modern script on SharePoint Online

Copper Contributor

I am trying to add LinkedIn company page feed on my SharePoint Online page. But facing CORS problem. Same linkedIn share api is working fine when tested on Postman and Curl. I have also tried using with nodejs. It is showing desired result in all the cases. But when I use it in SharePoint Online, using modern script editor then it shows CORS problem.

function myFunction()
var accessToken='************';
var requestUri = "<LinkedIn Share API URL>";
          url: requestUri,
          type: "GET",
          async: false,
          data:{count: 1},
          headers: {
            'Authorization': `Bearer ${accessToken}`,
            'cache-control': 'no-cache',
          success: onSuccess,
          error: onError
function onSuccess(data) 
    console.log("success: "+JSON.stringify(data));
function onError(error) {
    console.log('LinkedIn Error: '+JSON.stringify(error));


Console Error:

Access to XMLHttpRequest at '********&sharesPerOwner=1&count=1&count=1' from origin '' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

9 Replies

@Toby Statham I am accessing linkedIn share api through jquery Ajax method in sharePoint online modern script editor.

Not sure exactly what you're trying to do, but this doesn't look like the correct way to access the LinkedIn APIs. Where did you get this example from? 


Here is the developer documentation for LinkedIn -



@Toby Statham 

We are using the webpart with No Javascript language now. When we are trying to connect the Share web api of the LinkedIn. It is giving the CORS error. I'm also attached the No Javascript typescript file for you info. API call is in the LoadData() function.

Kindly provide the help asap.

@nilesh1011 Have you added the tenant URL as an SDK in your LinkedIn application as detailed here -

@nilesh1011 I wasn't referring to the SDK, just the section you need to add your tenant URL to. 


It's slightly changed, but you need to add your tenant domain to the Widgets section in your LinkedIn app settings.

@Toby Statham Yes! I have added tenant domain to the Widgets section in my LinkedIn app settings. But still showing cors problem.






I got same issue, how did you fix the preflight cors issue ?