Reputation: 462
I'm face an error with LinkedIn Rest API. I try to post on my company page. I face error. When I post on my LinkedIn profile. That is fine. But in company page I show an error.
{
"serviceErrorCode": 100,
"message": "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/owner]",
"status": 403
}
I use share API, API URL https://api.linkedin.com/v2/shares. my error related to "owner": "urn: li: organization:76615898". I'm pass correctly, my company page https://www.linkedin.com/company/76615898/.
{
"content": {
"contentEntities": [
{
"entityLocation": "https://officialrajdeepsingh.dev/how-to-create-web-stories-on-ghost-cms/",
"thumbnails": [
{
"resolvedUrl": "https://officialrajdeepsingh.dev/content/images/size/w2000/2022/02/Amp-ghost-cms--configation.png"
}
]
}
],
"title": "How to create web stories on Ghost CMS",
"description": "The google web story helps websites to grow very fast. We enable AMP web stories on your website for free in the post."
},
"distribution": {
"linkedInDistributionTarget": {}
},
"owner": "urn:li:organization:76615898",
"subject": "The google web story helps websites to grow very fast. We enable AMP web stories on your website for free in the post.",
"text": {
"text": "How to create web stories on Ghost CMS"
}
}
Get code
Get access token
I use the get method to create successful code.
GET https://www.linkedin.com/oauth/v2/authorization?
response_type=code&client_id=77d*******oo56&redirect_uri=https://officialrajdeepsingh.dev&state=testfoobar&scope=r_liteprofile%2520r_emailaddress%2520w_member_social
I use the post command to get successfully access token
POST https://www.linkedin.com/oauth/v2/accessToken HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
code=code-here
redirect_uri=https://officialrajdeepsingh.dev
client_id=77d*********56
client_secret=ma***********Ch
Based on the token I try to create a post on my LinkedIn page.
OAuth 2.0 scopes
Products
For permission I add both 3 permission, to create a post on the LinkedIn page.
I add both three products to my app.
I do not know, what happen in code. I'm also use ugcPosts endpoint to share post on my company page. But do not work. https://api.linkedin.com/v2/ugcPosts With ugcPosts, I'm also face error
{
"serviceErrorCode": 100,
"message": "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]",
"status": 403
}
Please tell me how to solve my error with share https://api.linkedin.com/v2/shares point and how to solve it.
Upvotes: 0
Views: 289
Reputation: 143
This worked for me:
I created an access token with Oauth tools insted of doing in a CURL request. https://www.linkedin.com/developers/tools/oauth?clientId=YOUR_CLIENT_ID
After saving the access token and the access refresh in a save place, I was redirected to allow my app publish (though the API) on my behalf (my linkedin user).
After doing that, you should have allowed to your app to publish on your behalt. You can check that under: https://www.linkedin.com/mypreferences/d/data-sharing-for-permitted-services
Upvotes: 1