12-09-2024 05:50 PM
Prior to creating an inventory item, I am attempting to create an inventory location (which is an odd requirement considering how many of us sellers don't have a 'warehouse', 'store' or 'fulfillment center', but I digress), which from what I can tell is required in order to publish an offer (which comes after creating an offer for a created inventory item...?)
I'm getting this fantastically unhelpful error:
2024-12-10 01:30:32,174 - urllib3.connectionpool - DEBUG - https://api.sandbox.ebay.com:443 "PUT /sell/inventory/v1/location/user_105987699652522530866_location HTTP/1.1" 400 182
2024-12-10 01:30:32,056 - celery_app - DEBUG - Location Payload: {'name': 'XXXXX Shipping Location', 'location': {'address': {'postalCode': 'XXXXX', 'country': 'US'}}, 'merchantLocationStatus': 'ENABLED', 'locationTypes': ['WAREHOUSE'], 'locationInstructions': 'Default shipping location'}
2024-12-10 01:30:32,057 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.sandbox.ebay.com:443
2024-12-10 01:40:51,294 - celery_app - ERROR - Failed to create/update inventory location: {'errors': [{'errorId': 2004, 'domain': 'ACCESS', 'category': 'REQUEST', 'message': 'Invalid request', 'longMessage': 'The request has errors. For help, see the documentation for this API.'}]}
Here's my code:
# Create or update inventory location with user's address
inventory_location_key = f"user_{user_id}_location"
location_payload = {
"location": {
"address": {
"postalCode": user.postal_code,
"country": "US" # Required field
}
},
"phone": "5555555555", # Required field per API docs
"merchantLocationStatus": "ENABLED",
"locationTypes": ["WAREHOUSE"], # Using WAREHOUSE as the simplest type
"name": f"Shipping Location {user.postal_code}" # Optional for WAREHOUSE type
}
current_app.logger.debug(f"Location Payload: {location_payload}")
# Create or replace inventory location
location_response = client.put(
get_api_endpoint(f'sell/inventory/v1/location/{inventory_location_key}'),
json=location_payload,
headers={
'Content-Language': 'en-US',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
)
if not location_response.ok:
error_details = location_response.json()
current_app.logger.error(f"Failed to create/update inventory location: {error_details}")
return jsonify({
'success': False,
'message': 'Failed to create/update inventory location',
'error': error_details
}), location_response.status_code
04-03-2025 02:14 PM
Same issue: did you ever find a solution? Thanks!
07-05-2025 12:29 AM
Use a current active location pull one using this python script
Im using a .env file to store things like EBAY_ACCESS_TOKEN
import os
import requests
from dotenv import load_dotenv
load_dotenv("inputs.env")
TOKEN = os.getenv("EBAY_ACCESS_TOKEN")
headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json"
}
response = requests.get("https://api.ebay.com/sell/inventory/v1/location", headers=headers)
print("📍 Status Code:", response.status_code)
print("📦 Response:", response.text)