admin管理员组

文章数量:1410712

Having trouble creating an ad with linkedin API (v2025-02)

I'm doing the following:

 BASE_API_URL = ";
 headers.Add("LinkedIn-Version", "202502");
 headers.Add("X-Restli-Protocol-Version", "2.0.0");
  1. Uploading an image to the account (I've tried set the owner the anization or the account)

    var uploadUrl = $"{BASE_API_URL}/images?action=initializeUpload";
    
    var request = new
    {
      initializeUploadRequest = new
      {
          //owner = $"urn:li:sponsoredAccount:{accountId}"
          owner = $"urn:... {anizationId}"
      }
    };
    

The image uploads fine - the imageId is stored under imageId.

  1. Afterwards I am creating content (linkedin post):

     var postUrl = $"{BASE_API_URL}/posts";
     var request = new
     {
         adContext = new
         {
             dscAdAccount = $"urn:li:sponsoredAccount:{accountId}",
             dscStatus = "ACTIVE",
             dscName = ad.externalAdName
         },
         author = {anizationId},
         commentary = "Commentery goes here",
         visibility = "PUBLIC",
         distribution = new
         {
             feedDistribution = "NONE",
             thirdPartyDistributionChannels = new object[] { }
         },
         content = new
         {
             //Also tried this - didn't work
             //media = new
             //{
             //    title = "Title of the Image",
             //    id = $"urn:li:image:{imageId}"
             //}
             article = new
             {
                 title = ad.externalAdName,
                 thumbnail = $"urn:li:image:{imageId}",
                 source = ad.landingPage
             }
         },
         contentCallToActionLabel = ad.externalAdCTA,
         contentLandingPage = ad.landingPage,
         lifecycleState = "PUBLISHED",
         isReshareDisabledByAuthor = true
     };
    

Up to here everything works. id is saved under postId. Now is the problem - creating the ad:

  1. Create a new creative

     var createCreativeUrl = $"{BASE_API_URL}/adAccounts/{asset.extId}/creatives";
     var newCreative = new
     {
         campaign = $"urn:li:sponsoredCampaign:{campaignId}",
         intendedStatus = "PAUSED",
         name = ad.externalAdName,
         content = new 
         {
             reference = postId
         }
     };
    

This failed with the response:

{"code":"CREATIVE_CREATE_FORBIDDEN","message":"Not permitted to create the creative. Please check your permissions and that account and campaign details are correct.","status":403}

I've checked permission issue: I'm billing admin (this is my account I am testing), the token has ads_rw (and many more permissions).

What am I missing?

Having trouble creating an ad with linkedin API (v2025-02)

I'm doing the following:

 BASE_API_URL = "https://api.linkedin/rest"
 headers.Add("LinkedIn-Version", "202502");
 headers.Add("X-Restli-Protocol-Version", "2.0.0");
  1. Uploading an image to the account (I've tried set the owner the anization or the account)

    var uploadUrl = $"{BASE_API_URL}/images?action=initializeUpload";
    
    var request = new
    {
      initializeUploadRequest = new
      {
          //owner = $"urn:li:sponsoredAccount:{accountId}"
          owner = $"urn:... {anizationId}"
      }
    };
    

The image uploads fine - the imageId is stored under imageId.

  1. Afterwards I am creating content (linkedin post):

     var postUrl = $"{BASE_API_URL}/posts";
     var request = new
     {
         adContext = new
         {
             dscAdAccount = $"urn:li:sponsoredAccount:{accountId}",
             dscStatus = "ACTIVE",
             dscName = ad.externalAdName
         },
         author = {anizationId},
         commentary = "Commentery goes here",
         visibility = "PUBLIC",
         distribution = new
         {
             feedDistribution = "NONE",
             thirdPartyDistributionChannels = new object[] { }
         },
         content = new
         {
             //Also tried this - didn't work
             //media = new
             //{
             //    title = "Title of the Image",
             //    id = $"urn:li:image:{imageId}"
             //}
             article = new
             {
                 title = ad.externalAdName,
                 thumbnail = $"urn:li:image:{imageId}",
                 source = ad.landingPage
             }
         },
         contentCallToActionLabel = ad.externalAdCTA,
         contentLandingPage = ad.landingPage,
         lifecycleState = "PUBLISHED",
         isReshareDisabledByAuthor = true
     };
    

Up to here everything works. id is saved under postId. Now is the problem - creating the ad:

  1. Create a new creative

     var createCreativeUrl = $"{BASE_API_URL}/adAccounts/{asset.extId}/creatives";
     var newCreative = new
     {
         campaign = $"urn:li:sponsoredCampaign:{campaignId}",
         intendedStatus = "PAUSED",
         name = ad.externalAdName,
         content = new 
         {
             reference = postId
         }
     };
    

This failed with the response:

{"code":"CREATIVE_CREATE_FORBIDDEN","message":"Not permitted to create the creative. Please check your permissions and that account and campaign details are correct.","status":403}

I've checked permission issue: I'm billing admin (this is my account I am testing), the token has ads_rw (and many more permissions).

What am I missing?

Share Improve this question edited Mar 10 at 12:36 Ziv Weissman asked Mar 10 at 12:29 Ziv WeissmanZiv Weissman 4,5564 gold badges30 silver badges63 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Apparently if the app is in development mode you need to manually insert the ad accounts it can affect (although I managed to upload an image to the account and create a post)

You can do it by visiting:
https://www.linkedin/developers/apps/{appId}/settings 
When you go into your application, you'll want to navigate to the "Products" tab, then you will want to click on "View Ad Accounts" next to the Advertising API. From there, you can add the ad accounts that your app manages.

本文标签: cFailed to create ads with linkedin APICREATIVECREATEFORBIDDENStack Overflow