skip to Main Content

I guess this is rather a general problem than ebay specific, but I am not sure: I am trying to send an XML request to the ebay developer API to retrieve an XML response. When using curl, everything works fine and I get an XML response telling me which API-keys are missing (if I would provide them via HTTP headers I would get a valid XML result):

curl -d '<!xml version="1.0" encoding="utf-8"?><findItemsByKeywordsRequest xmlns="http://www.ebay.com/marketplace/search/v1/services"><keywords>harry potter phoenix</keywords></findItemsByKeywordsRequest>' 
http://svcs.sandbox.ebay.com/services/search/FindingService/v1

Which leads to the correct response:

<?xml version='1.0' encoding='UTF-8'?>
<ms:errorMessage xmlns:ms="http://www.ebay.com/marketplace/services" xmlns="http://www.ebay.com/marketplace/search/v1/services">
    <error>
        <errorId>2038</errorId>
        <domain>CoreRuntime</domain>
        <severity>Error</severity>
        <category>System</category>
        <message>Missing SOA operation name header</message>
        <subdomain>System</subdomain>
    </error>
</ms:errorMessage>

But when I try to work with Python I just get “500 Internal Server error”, no matter how basic I make my examples. I have tried two very basic methods:

Number one:

serverUrl = 'svcs.sandbox.ebay.com'
xmlparameters = '<!xml version="1.0" encoding="utf-8"?><findItemsByKeywordsRequest xmlns="http://www.ebay.com/marketplace/search/v1/services"><keywords>harry potter phoenix</keywords></findItemsByKeywordsRequest>'

webservice = httplib.HTTP(serverUrl)
webservice.putrequest("POST", "/services/search/FindingService/v1")
webservice.putheader("Host", serverUrl)
webservice.putheader("Content-type", "text/xml; charset="UTF-8"")
webservice.putheader("Content-length", "%d" % len(xmlparameters))
webservice.endheaders()
webservice.send(xmlparameters)

Number two (which is my prefered method):

serverUrl = 'svcs.sandbox.ebay.com'
xmlparameters = '<!xml version="1.0" encoding="utf-8"?><findItemsByKeywordsRequest xmlns="http://www.ebay.com/marketplace/search/v1/services"><keywords>harry potter phoenix</keywords></findItemsByKeywordsRequest>'

connection = httplib.HTTPConnection(serverUrl)
connection.request("POST", '/services/search/FindingService/v1', xmlparameters)

As you can see in the CURL example, it does not matter that I do not send the API keys etc., it should return an XML error response anyway and not only HTTP status code “500 Internal server error”.

Does anyone see what I am doing wrong with my POST request?

[EDIT] btw using the URL ValueName API works perfectly with Python, but that’s just a GET request on a URL. Yet, I’d prefer to use the XML API. However, if that’s not possible I’d switch to ValueName URIs of course.

2

Answers


  1. The 500 response status is rather generic and should come back no matter what error is being thrown on the server. Would you consider using the CGI trackback to return the error message?

    http://docs.python.org/library/cgitb.html#module-cgitb

    Login or Signup to reply.
  2. It’s returning a 500 status and the xml response:

    >>> connection.request("POST", '/services/search/FindingService/v1', xmlparameters)
    >>> resp = connection.getresponse()
    >>> resp.status
    <<< 500
    >>> resp.read()
    <<< '<?xml version='1.0' encoding='UTF-8'?><ms:errorMessage xmlns:ms="http://www.ebay.com/marketplace/services" xmlns="http://www.ebay.com/marketplace/search/v1/services"><error><errorId>2038</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>System</category><message>Missing SOA operation name header</message><subdomain>System</subdomain></error></ms:errorMessage>'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search