07-01-2024 05:47 AM - edited 07-01-2024 05:48 AM
I'm using a translation site so I apologize if there are any grammatical errors.
I'm currently creating an application that uses Python to operate the eBay API.
I'm trying to register a test product in the SandBox environment to implement a function to delete products with a specified SKU, but it's not working.
Please let me know what I need to fix.
・Implementation with cURL
curl -X POST -i 'https://api.sandbox.ebay.com/sell/inventory/v1/inventory_item/TEST001' -H 'Accept: application/json' -H 'Accept-language: en-US' -H 'Content-type: application/json' -H 'Content-language: en-US' -H 'Authorization: Bearer v***' -d '{"availability": {"shipToLocationAvailability": {"quantity": 50}}, "condition": "NEW", "product": {"title": "GoPro Hero4 Helmet Cam", "description": "New GoPro Hero4 Helmet Cam. Unopened box.", "aspects": {"Brand": ["GoPro"], "Type": ["Helmet/Action"], "Storage Type": ["Removable"], "Recording Definition": ["High Definition"], "Media Format": ["Flash Drive (SSD)"], "Optical Zoom": ["10x"]}, "brand": "GoPro", "mpn": "CHDHX-401"}}'
・Implementation in Python
req_header = {
"Accept": "application/json",
"Accept-Language": "en-US",
"Authorization": "Bearer " + aToken,
"Content-Type": "application/json",
"Content-Language": "en-US",
}
req_data = {
"availability": {
"shipToLocationAvailability": {
"quantity": 50
}
},
"condition": "NEW",
"product": {
"title": "GoPro Hero4 Helmet Cam",
"description": "New GoPro Hero4 Helmet Cam. Unopened box.",
"aspects": {
"Brand": ["GoPro"],
"Type": ["Helmet/Action"],
"Storage Type": ["Removable"],
"Recording Definition": ["High Definition"],
"Media Format": ["Flash Drive (SSD)"],
"Optical Zoom": ["10x"]
},
"brand": "GoPro",
"mpn": "CHDHX-401"
}
}
req = urllib.request.Request(inventory_url_sandbox + SKU, data=json.dumps(req_data).encode("utf-8"), headers=req_header)
response = None
try:
response = urllib.request.urlopen(req).read()
except Exception as e:
print(e)
・Error message
400 Bad Request
{"errors":[{"errorId":2004,"domain":"ACCESS","category":"REQUEST","message":"Invalid request","longMessage":"The request has errors. For help, see the documentation for this API."}]}
07-15-2024 12:22 AM