1

i try to use the PYTHON-AMAZON-AD-API packeg and i have my credentials as a dict with refresh_token, client_id, client_secret and profile_id. an it looks like everything is ok but when i try this code:

try:

    status = 'enabled'

    result=sponsored_products.Campaigns(credentials=credentials, debug=True).list_campaigns(
        stateFilter=status
    )

    payload = result.payload

    logging.info(payload)

except AdvertisingApiException as error:

    logging.info(error)

i get ( i deleted the sensitive details from here) :

2023-09-04 11:46:39,312:WARNING:Call to deprecated function list_campaigns endpoint: /v2/sp/campaigns method: GET
2023-09-04 11:46:41,691:INFO:{'User-Agent': 'python-ad-api-0.4.9', 'Amazon-Advertising-API-ClientId': 'XXXXXXXX', 'Authorization': 'Bearer XXXXXX', 'Amazon-Advertising-API-Scope': 'XXXXXX', 'Content-Type': 'application/json'}
2023-09-04 11:46:41,693:INFO:GET https://advertising-api-test.amazon.com/v2/sp/campaigns?stateFilter=enabled
2023-09-04 11:46:41,693:INFO:{'_content': b'<html><body><b>Http/1.1 Service Unavailable</b></body> </html>', '_content_consumed': True, '_next': None, 'status_code': 503, 'headers': {'Server': 'Server', 'Date': 'Mon, 04 Sep 2023 09:46:41 GMT', 'Content-Length': '62', 'Connection': 'keep-alive', 'x-amz-rid': 'HMG7GXBXW27ZJ9VV1NGP', 'Cache-Control': 'no-cache,no-store', 'Pragma': 'no-cache', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'}, 'raw': <urllib3.response.HTTPResponse object at 0x00000185E2DD26E0>, 'url': 'https://advertising-api-test.amazon.com/v2/sp/campaigns?stateFilter=enabled', 'encoding': None, 'history': [], 'reason': 'Service Unavailable', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(seconds=1, microseconds=72272), 'request': <PreparedRequest [GET]>, 'connection': <requests.adapters.HTTPAdapter object at 0x00000185E2D917D0>}
2023-09-04 11:46:41,694:INFO:(503, b'<html><body><b>Http/1.1 Service Unavailable</b></body> </html>', {'Server': 'Server', 'Date': 'Mon, 04 Sep 2023 09:46:41 GMT', 'Content-Length': '62', 'Connection': 'keep-alive', 'x-amz-rid': 'HMG7GXBXW27ZJ9VV1NGP', 'Cache-Control': 'no-cache,no-store', 'Pragma': 'no-cache', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'})

I dont get why i always get 'status_code': 503 ....

Can someone help me with it? what should i do?

i expect to get a list of my campaigns

2
  • A 503 status code indicates a "Service Unavailable" HTTP response. So in summary, a 503 status indicates a temporary inability to handle requests, not a permanent failure... so you should retry the request later based on the Retry-After header rather than treating it as an outright failure. Commented Sep 4, 2023 at 17:05
  • The python-amazon-ad-api package appears to be out of date and calling deprecated endpoints of Version 2 of the Amazon Ads API for Sponsored Products. I had the same issue. You should try to call the Version 3 endpoints instead: advertising.amazon.com/API/docs/en-us/sponsored-products/3-0/… Commented Sep 28, 2023 at 11:14

1 Answer 1

0

Amazon Ads advertising API has deprecated the Version 2 endpoints for Sponsored Products on March 27, 2024.

So Kindly use the CampaignsV3.list_campaigns() method to fetch the list of campaigns.

Here's the link the corresponding python package documentation.

https://python-amazon-ad-api.readthedocs.io/en/latest/sp/campaigns_v3.html#ad_api.api.sp.CampaignsV3.CampaignsV3.list_campaigns

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.