Im using request python to call api from AE-Affiliate Aliexpress. But got error “The request signature does not conform to platform standards”
This is the code that I used for requesting API
def generatesign(api_name,appSecret,params):
parameters=[]
for key,value in params.items():
if key=="sign":
continue
if len(value)>0:
parameters.append(key+value)
parameters=sorted(parameters)
if "/" in api_name:
concatenated=api_name+"".join(parameters)
else:
concatenated = "".join(parameters)
sig = hmac.new(appSecret.encode(), concatenated.encode(), hashlib.sha256)
return sig.hexdigest().upper(),concatenated
time_stamp = str(int(time.time() * 1_000_000))
params2 = {
'access_token': 'my_acess_token',
'app_key': 'my_appkey',
'format': 'json',
'method': 'aliexpress.ds.freight.query',
'partner_id': 'iop-sdk-python-20220609',
'queryDeliveryReq': '{"productId":"3256806253680321","selectedSkuId":"12000037172759189","quantity":1,"shipToCountry":"US","source":"","currency":"","language":"","locale":"EN"}',
'session': 'my_acess_token',
'sign_method': 'sha256',
'simplify': 'false',
}
sign,check=generatesign("https://api-sg.aliexpress.com/sync?","MhCSYFLKUxp4gd0NvryILtoc6XlT76IN",params2)
params2["sign"]=sign
params2['timestamp']=time_stamp
response = requests.post('https://api-sg.aliexpress.com/sync?', params=params2,cookies=cookies, headers=headers)
But I give me an error IncompleteSignature.
I want response like this
{
"aliexpress_ds_freight_query_response": {
"result": {
"msg": "Item is not allowed to this country",
"code": 602,
"success": false
},
"request_id": "210126da17235447546796602"
}
}
New contributor
Luân Nguyễn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.