Megha Sirisilla
Megha Sirisilla

Reputation: 151

Ebay Integration with Python

I have to integrate my django project with Ebay. I have followed the SDK repository and set up an account on the developers forum as specified here Ebay SDK Repository for Python

I tried to run the following function to add an item

#!/usr/bin/env python3

from ebaysdk.trading import Connection

if __name__ == '__main__':
    api = Connection(config_file="ebay.yaml", domain="api.sandbox.ebay.com", debug=True)
    request = {
    "Item": {
        "Title": "Professional Mechanical Keyboard",
        "Country": "US",
        "Location": "IT",
        "Site": "US",
        "ConditionID": "1000",
        "PaymentMethods": "PayPal",
        "PayPalEmailAddress": "[email protected]",
        "PrimaryCategory": {"CategoryID": "33963"},
        "Description": "A really nice mechanical keyboard!",
        "ListingDuration": "Days_10",
        "StartPrice": "150",
        "Currency": "USD",
        "ReturnPolicy": {
            "ReturnsAcceptedOption": "ReturnsAccepted",
            "RefundOption": "MoneyBack",
            "ReturnsWithinOption": "Days_30",
            "Description": "If you are not satisfied, return the keyboard.",
            "ShippingCostPaidByOption": "Buyer"
        },
        "ShippingDetails": {
            "ShippingServiceOptions": {
                "FreeShipping": "True",
                "ShippingService": "USPSMedia"
            }
        },
        "DispatchTimeMax": "3"
    }
}

api.execute("AddItem", request)

but then I'm running into the following errors

ebaysdk.exception.ConnectionError: "AddItem: Class: RequestError, Severity: Error, Code: 120, You need to create a seller's account. Before you can list this item we need some additional information to create a seller's account."

020-01-16 17:13:02,385 ebaysdk [WARNING]:AddItem: Class: RequestError, Severity: Warning, Code: 21920200, Return Policy Attribute Not Valid Return Policy Attribute returnDescription Not Valid On This Site

I am not getting how to set a seller account or return policy on Ebay. I did a lot of R&D from my side but couldn't find a solution. Any help with this will be highly appreciated.

Upvotes: 0

Views: 941

Answers (1)

nagateja sharaf
nagateja sharaf

Reputation: 21

You have something wrong in your credentials please copy sand box credentials and if you want to generate auth token go to this url : https://developer.ebay.com/DevZone/build-test/test-tool/?index=0 and generate token and if you want to find your sand box credentials visit : https://developer.ebay.com/my/keys and if you are new user please sign up to ebay and it may take one week or 2 days to accept your account and for registration please visit : https://developer.ebay.com/signin

ebay-yaml file:

name: ebay_api_config

# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
    compatability: 719
    appid: ENTER_YOUR_APPID_HERE
    certid: ENTER_YOUR_CERTID_HERE
    devid: ENTER_YOUR_DEVID_HERE
    token: ENTER_YOUR_TOKEN_HERE

# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
    compatability: 719
    appid: ENTER_YOUR_APPID_HERE
    certid: ENTER_YOUR_CERTID_HERE
    devid: ENTER_YOUR_DEVID_HERE
    token: ENTER_YOUR_TOKEN_HERE

# Finding API - https://www.x.com/developers/ebay/products/finding-api
svcs.ebay.com:
    appid: ENTER_YOUR_APPID_HERE
    version: 1.0.0

# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
open.api.ebay.com:
    appid: ENTER_YOUR_APPID_HERE
    version: 671

additem code:

#!/usr/bin/env python3
from ebaysdk.trading import Connection

if __name__ == '__main__':
    api = Connection(config_file="<your-yaml-file-path>", domain="api.sandbox.ebay.com", debug=True)
    request = {
        "Item": {
            "Title": "Professional Mechanical Keyboard",
            "Country": "US",
            "Location": "IT",
            "Site": "US",
            "ConditionID": "1000",
            "PaymentMethods": "PayPal",
            "PayPalEmailAddress": "[email protected]",
            "PrimaryCategory": {"CategoryID": "33963"},
            "Description": "A really nice mechanical keyboard!",
            "ListingDuration": "Days_10",
            "StartPrice": "150",
            "Currency": "USD",
            "ReturnPolicy": {
                "ReturnsAcceptedOption": "ReturnsAccepted",
                "RefundOption": "MoneyBack",
                "ReturnsWithinOption": "Days_30",
                "Description": "If you are not satisfied, return the keyboard.",
                "ShippingCostPaidByOption": "Buyer"
            },
            "ShippingDetails": {
                "ShippingServiceOptions": {
                    "FreeShipping": "True",
                    "ShippingService": "USPSMedia"
                }
            },
            "DispatchTimeMax": "3"
        }
    }
    d=api.execute("AddItem", request)
    print(d)

Upvotes: 2

Related Questions