cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

Hello eBay Developer Community,

 

I'm encountering an issue while attempting to create an inventory item for a sports trading card on eBay via the Sell Inventory API. Despite following the documentation and ensuring all required fields are populated, I keep receiving a `2004: Invalid request` error upon submission.

 

Code

async def create_ebay_inventory_item()-> None:
    sku = "cbfb7f2b-b099-45d1-b45c-a4fe1d488aa6"
    url_create_inventory_item = f"https://api.ebay.com/sell/inventory/v1/inventory_item/{sku}"
    inventory_item_data = {
        "sku": sku,
        "condition": "LIKE_NEW",
        "conditionDescription": "Graded - PSA 9",
        "conditionDescriptors": [
            {
            "name": "Certification Number",
            "value": "55753296"
            },
            {
            "name": "Grading Company",
            "value": "PSA"
            },
            {
            "name": "Grade",
            "value": "9"
            }
        ],
        "availability": {
            "shipToLocationAvailability": {
            "quantity": 1
            }
        },
        "product": {
            "title": "2019 Panini Prizm Goga Bitadze 264 PSA 9",
            "description": "2019 Panini Prizm Goga Bitadze card #264, graded by PSA as 9.0 (Mint). Capture a moment of NBA history with this high-demand rookie card.",
            "brand": "Panini Prizm",
            "imageUrls": [
                "https://example.com/image_front.png",
                "https://example.com/image_back.png"
            ],
            "aspects": {
            "Brand": "Panini Prizm",
            "Year": "2019",
            "Player": "Goga Bitadze",
            "Card Number": "264",
            "Type": "Sports Trading Card",
            "Sport": "Basketball"
            }
        }
    }
    
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {token}',
        'Accept': 'application/json',
    }

    response = requests.post(url=url_create_inventory_item, headers=headers, data=json.dumps(inventory_item_data))
    if response.status_code == 200 or response.status_code == 201:
        print("Inventory item created successfully.")
        print(response)
    else:
        error_details = response.json()
        print("Error details:")
        print(json.dumps(error_details, indent=4))

Error

{
    "errors": [
        {
            "errorId": 2004,
            "domain": "ACCESS",
            "category": "REQUEST",
            "message": "Invalid request",
            "longMessage": "The request has errors. For help, see the documentation for this API."
        }
    ]
}

 

**Attempts to Resolve**:
- Verified that the OAuth token is active and has the necessary permissions.
- Ensured all required `condition`, `availability`, and `product` fields are provided, with attention to details like `brand`, `title`, and `SKU`.
- Double-checked for correct use of enumeration values (e.g., `condition` field).
- Looked into whether the SKU included in the URL might be the issue.

**Questions**:
1. Is including the SKU in the endpoint URL correct, or should it only be part of the payload?
2. Are there known issues or recent changes to the `conditionDescriptors` handling for sports trading cards that could lead to this error?
3. Could the `Invalid request` error pertain to the structure or content of the payload that isn't immediately apparent from the documentation?
4. Any suggestions or insights into what might be causing the `2004: Invalid request` error, based on the information provided?

I would greatly appreciate any guidance, insights, or suggestions you could share to help resolve this issue.

Thank you in advance for your assistance!

Message 1 of 5
latest reply
1 BEST ANSWER

Accepted Solutions

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

@altxyzofficial 

 

I have not used the inventory API, so this is just a general observation.

I do see a problem surrounding conditionDescriptors, but I don't know if this is the only issue.

For CCGs that are graded, the condition is 2750 (I assume either the number or the enumeration would work, but don't know that as a fact). The conditionDescriptors consist of one additionalInfo that is the certification number, and two name/value pairs for the company and the grade. These NV pairs are numerical IDs. 

 

eBay has these numerical IDs somewhere, and I got tired of looking for them for sellers who were bulk updating their listings through a CSV upload, so created a spreadsheet cheat sheet here:

https://www.shipscript.com/ebayhelp/sellerhub/example_card_revisions.htm

 

Below is the JSON structure for the createOrReplaceInventoryItem call, as shown on this page:

https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/createOrReplaceI...  

 

"condition" : "ConditionEnum : [NEW,LIKE_NEW,NEW_OTHER...]",
"conditionDescription" : "string",
"conditionDescriptors" : [
  { /* ConditionDescriptor */
    "additionalInfo" : "string",
    "name" : "string",
    "values" : [
      "string"
    ]
  }
],

 

Scroll down to "Request Fields" on the inventory page to read the highlighted notes about conditionDescriptors and trading cards:

 

"This string provides the name of a condition descriptor. A numeric ID is passed in this field. This numeric ID maps to the name of a condition descriptor. "

 

Both the name and the value are numeric IDs, thus I would refer you back to the cheat sheet that I made.  Notice that "values" is plural and is an array, but can not be an array in trading cards, so I'm not sure whether you need the array designation in  the JSON representation below.

 

        "conditionDescriptors": [
            {
            "additionalInfo": "55753296"
            },
            {
            "name": "27501",
            "values": ["275010"]
            },
            {
            "name": "27502",
            "values": ["275022"]
            }
        ]

 

As I said, I've not used the Inventory API, so take this as a suggestion of where to start experimenting. I also wonder how the inventory upload could work without a Category ID to process the trading card conditionDescriptors.

 

 

 

ShipScript has been an eBay Community volunteer since 2003, specializing in HTML, CSS, Scripts, Photos, Active Content, Technical Solutions, and online Seller Tools.

View Best Answer in original post

Message 3 of 5
latest reply
4 REPLIES 4

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

Following payload has been working fine for me, try to compare and see the difference.

 

https://api.ebay.com/sell/inventory/v1/inventory_item/4002261

 

 

 

{ "sku": "4002261", "product": { "title": "Shock Strut Spring Assembly 2004-2008 NISSAN-MAXIMA 84002261", "aspects": { "Brand": [ "dssadsa" ], "Type": [ "Other Vintage Auto Brochures" ], "Color": [ "See pictures" ], "Item Height": [ "0 cm" ], "Style": [ "Modern" ], "MPN": [ "002261" ], "Material": [ "See description" ], "Item Length": [ "0 cm" ], "Item Depth": [ "0 cm" ], "Item Width": [ "0 cm" ] }, "brand": "ZNTS", "mpn": "GT-84002261", "imageUrls": [ "https://img-accelerate/Resources/GoodsImages/2020/202008/44861260/2008241833370241.jpg" ] }, "condition": "NEW", "availability": { "shipToLocationAvailability": { "quantity": 1, "allocationByFormat": { "auction": 0, "fixedPrice": 1 } } } }

 

 

Your "aspects" does not look correct to me, so I would recommend, take my payload and make changes and then see where it fails.

 

C# wrapper for eBay REST API
https://github.com/CMS365-PTY-LTD/EbaySharp
Message 2 of 5
latest reply

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

@altxyzofficial 

 

I have not used the inventory API, so this is just a general observation.

I do see a problem surrounding conditionDescriptors, but I don't know if this is the only issue.

For CCGs that are graded, the condition is 2750 (I assume either the number or the enumeration would work, but don't know that as a fact). The conditionDescriptors consist of one additionalInfo that is the certification number, and two name/value pairs for the company and the grade. These NV pairs are numerical IDs. 

 

eBay has these numerical IDs somewhere, and I got tired of looking for them for sellers who were bulk updating their listings through a CSV upload, so created a spreadsheet cheat sheet here:

https://www.shipscript.com/ebayhelp/sellerhub/example_card_revisions.htm

 

Below is the JSON structure for the createOrReplaceInventoryItem call, as shown on this page:

https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/createOrReplaceI...  

 

"condition" : "ConditionEnum : [NEW,LIKE_NEW,NEW_OTHER...]",
"conditionDescription" : "string",
"conditionDescriptors" : [
  { /* ConditionDescriptor */
    "additionalInfo" : "string",
    "name" : "string",
    "values" : [
      "string"
    ]
  }
],

 

Scroll down to "Request Fields" on the inventory page to read the highlighted notes about conditionDescriptors and trading cards:

 

"This string provides the name of a condition descriptor. A numeric ID is passed in this field. This numeric ID maps to the name of a condition descriptor. "

 

Both the name and the value are numeric IDs, thus I would refer you back to the cheat sheet that I made.  Notice that "values" is plural and is an array, but can not be an array in trading cards, so I'm not sure whether you need the array designation in  the JSON representation below.

 

        "conditionDescriptors": [
            {
            "additionalInfo": "55753296"
            },
            {
            "name": "27501",
            "values": ["275010"]
            },
            {
            "name": "27502",
            "values": ["275022"]
            }
        ]

 

As I said, I've not used the Inventory API, so take this as a suggestion of where to start experimenting. I also wonder how the inventory upload could work without a Category ID to process the trading card conditionDescriptors.

 

 

 

ShipScript has been an eBay Community volunteer since 2003, specializing in HTML, CSS, Scripts, Photos, Active Content, Technical Solutions, and online Seller Tools.
Message 3 of 5
latest reply

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

Thanks for helping out. I tried those and seems like the issue is around conditionDescriptors, I am not able to pinpoint what the issue there is though

Message 4 of 5
latest reply

Help Needed with "Invalid Request" Error When Creating Inventory Item via eBay API

this might be it, i pinpointed the issue to conditionDescriptors. Will try it out tomorrow and update, Thanks for the input.

Message 5 of 5
latest reply