Integration into Python

  • philatelie-weltweit

    13 berichten

    Duitsland

    Hello :)

    We are trying to integrate the API into our Python application.

    However, we are not sure what the error messages mean that are thrown from the endpoint.

    We would expect similar behavior for the PHP from the GitHub repo and our Python scripts.

    Yet, we are also not sure what kind of request is expected.

    Do you have any ideas how to construct an appropriate request for the API in Python?

    The script:

    acimport requests

    # define the data payload
    postData = {
    'type': 'fixedPrice',
    'item': {
    # MANDATORY DATA
    'id_category': 80,
    'fixed_price': '1.00',
    'currency': 'EUR',
    'title': 'My title',
    'personal_reference': 'My personal ref',
    # OPTIONAL IMAGES
    'images': [
    ' Link (http)
    ' Link (http) '
    ]
    }
    }

    headers = {
    'User-Agent': 'MyApp/1.0',
    'Content-Type': 'application/json',
    }

    # define the endpoint URL
    url = ' Link (https) '

    # make the HTTP POST request
    response = requests.post(url, json=postData, headers = headers)

    # print the response content and effective URL
    print(response.content)
    print(response.url)
  • @kevin
    Beheerder

    102 berichten

    België

    Hi philatelie-weltweit,

    Can you provide me with the error message you receive ?
    Normally, you have two api-keys: one for your tests and one "official".
    Which one did you use ?

    I also advise you to not communicate your key or token on the forum because this information is personal.
    I just edited your message to remove the token provided.

    Best regards,
    --
    Kevin
    The Delcampe team
  • philatelie-weltweit

    13 berichten

    Duitsland

    Great, thank you. So, we are now experiencing the issue that the new token is no longer valid, both in PHP and Python (Error 403). Before this, we either received server error 500 or there were some formatting issues with the query string.

    Could you give an example on how to format a corresponding query string?
  • @fred
    Beheerder

    127 berichten

    België

    Great, thank you. So, we are now experiencing the issue that the new token is no longer valid, both in PHP and Python (Error 403). Before this, we either received server error 500 or there were some formatting issues with the query string.

    Could you give an example on how to format a corresponding query string?
    • Aangemaakt 28 apr 2023 op 05:15
    • #1552183
    Hi philatelie-weltweit,

    The token given in reponse of the /seller endpoint is only valid 30mn. You'll have to get a new token once it expires.

    For the 500 error, was there an error message in the response ?

    Regards,
    Fred
  • philatelie-weltweit

    13 berichten

    Duitsland

    \n err_item_incorrectIdCategory\n
  • philatelie-weltweit

    13 berichten

    Duitsland

    \n err_item_incorrectIdCategory\n
  • philatelie-weltweit

    13 berichten

    Duitsland

    \n err_item_incorrectIdCategory\n
  • philatelie-weltweit

    13 berichten

    Duitsland

    Okay, sorry we can not provide you the XML response as the backend parses it
    Please delete the posts from before:

    The essential information from the response is:

    Response Code: 400

    err_item_incorrectIdCategory
  • @kevin
    Beheerder

    102 berichten

    België

    Hi philatelie-weltweit,

    The error that you have means that you have an error in the ID category encoded.

    Here you can find all the category ids you can use.
    Be careful to not use categories containing other categories (use just child)
    Link (https)

    Best regards,
    --
    Kevin
    The Delcampe team
  • philatelie-weltweit

    13 berichten

    Duitsland

    Dear Kevin,

    Of course, we do understand the error message, yet in PHP, it makes no problem. It is the code from your code example in fact (code 80).

    It would be helpful if you provided a plain request we can use in Python, e.g a query URL or something similar.

    We can't really debug it as we do not receive the full error message with a stack trace. We hope you could collaborate with us in that regard.
  • @kevin
    Beheerder

    102 berichten

    België

    Hi philatelie-weltweit,

    Unfortunately we don't have Python support.
    We only provide a rest API. All available query URLs can be found in our official documentation.

    Best regards,
    --
    Kevin
    The Delcampe team
  • philatelie-weltweit

    13 berichten

    Duitsland

    Dear Kevin,

    Thank you for your assistance. We understand your perspective. Would you kindly help us then on how to query the REST API with curl from the command line?

Word lid van de verzamelaars-community!

Registreren Aanmelden