amzn / ads-advanced-tools-docs

Code samples and supplements for the Amazon Ads advanced tools center
https://advertising.amazon.com/API/docs/en-us/index
MIT No Attribution
87 stars 33 forks source link

PUT /sp/campaigns update campaings success but not work!!?? #212

Closed CoderWeiAden closed 7 months ago

CoderWeiAden commented 7 months ago

I want to remove a Sponsored Products (SP) advertising campaign from an advertising portfolio. My parameters are: {"campaigns":[{"campaignId":"365657908139493","portfolioId":""}]}

The API I called is: PUT /sp/campaigns

The returned result is: {"campaigns":{"error":[],"success":[{"campaignId":"365657908139493","index":0}]}}

It can be seen that there is no error reported, but why does this campaign still exist within the advertising portfolio?

Later, setting the PortfolioID to null or "0" did not have any effect.

elizafarley commented 7 months ago

Hi @CoderWeiAden, you should be able to use PUT /sp/campaigns to set the portfolioId to null and remove the campaign from the portfolio. If that isn't working, I'd suggest opening a ticket with our support team to engineering can take a look.

CoderWeiAden commented 7 months ago

Hi @CoderWeiAden, you should be able to use PUT /sp/campaigns to set the portfolioId to null and remove the campaign from the portfolio. If that isn't working, I'd suggest opening a ticket with our support team to engineering can take a look.

sorry,i set portfolioId to null,but the cmapaign is not remove from the portfolio, can you please give me the complete params for remove campaign from portfolio ,thank you!

elizafarley commented 7 months ago

I was able to successfully remove a portfolioId reference from a campaign with this request:

curl --location --request PUT 'https://advertising-api.amazon.com/sp/campaigns' \
--header 'Amazon-Advertising-API-ClientId: amzn1.application-oa2-client.xxxxxxxx' \
--header 'Authorization: Bearer Atza|xxxxxxxxx' \
--header 'Amazon-Advertising-API-Scope: xxxxxxxxx' \
--header 'Prefer: return=representation' \
--header 'Accept: application/vnd.spCampaign.v3+json' \
--header 'Content-Type: application/vnd.spCampaign.v3+json' \
--data '{
  "campaigns": [
    {
      "campaignId": "1234567",
      "portfolioId": null
    }
  ]
}'