Search code examples
linkedin-api

Anyone Else Experiencing "Internal Server Error" When Registering an Image?


Is anyone else experiencing Internal Server Error when trying to register an image? I followed the instructions here (https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin?context=linkedin/consumer/context#create-an-image-share) and even tried on 2 apps but I get the same error.

I checked this https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/vector-asset-api#register-an-upload as well, even if it only pertains to uploading videos.

Things I made sure:

- content type = application/json
- X-Restli-Protocol-Version - 2.0.0

Am I missing something? Is there a specific permission needed for it?

EDIT for more info:

URL: https://api.linkedin.com/v2/assets?action=registerUpload

Headers:

Authorization: Bearer <token_here>
X-Restli-Protocol-Version: 2.0.0
Content-Type: application/json

Body:

{\"registerUploadRequest\":{\"recipes\":[\"urn:li:digitalmediaRecipe:feedshare-image\"],\"owner\":\"urn: li:person:PERSONID\",\"serviceRelationships\":[{\"relationshipType\":\"OWNER\",\"identifier\":\"urn:li:userGeneratedContent\"}]}}

EDIT:

Finally was able to get past through the registration process. A sneaky space character was in my JSON body. I'm now able to register, upload the image, and do a share.


Solution

  • The comment by @Ervin Kalemi helped - it turns out the Asset wasn't yet available. Also - I think the mistake you're making is that you're sending the content type and linkedin header. For the actual CURL post the following worked for me (using PHP):

    exec('curl --upload-file '.$img.' --header "'.$this->oauth[0].'" \''.$url.'\'');

    $img is the file path and $this->oauth[0] is simply Authorization: Bearer $token. I couldnt however get the above working with PHP curl - I had to run it directly as above. So if there is a php-curl solution I would prefer to use that. But hopefully this will get you going.