Shanni Piha
Shanni Piha

Reputation: 11

Amazon Ads API with PYTHON-AMAZON-AD-API packeg

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

Upvotes: 1

Views: 221

Answers (1)

Vignesh Sivaraman
Vignesh Sivaraman

Reputation: 1

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

Upvotes: 0

Related Questions