timotheus / ebaysdk-python

eBay API SDK for Python
https://developer.ebay.com/tools/sdks
Other
809 stars 326 forks source link

AttributeError: 'Response' object has no attribute '_dom' #84

Open oerp-odoo opened 10 years ago

oerp-odoo commented 10 years ago

I get mentioned error when running this piece of code:

from ebaysdk.shopping import Connection as Shopping
api = Trading(domain='api.sandbox.ebay.com', config_file="ebay.yaml")
shopping = Shopping(domain="svcs.sandbox.ebay.com", config_file="ebay.yaml")
response = shopping.execute('FindPopularItems',
           {'QueryKeywords': 'Python'})
print response.disct()

Whole error:

Traceback (most recent call last):
  File "ebay-test.py", line 8, in <module>
    {'QueryKeywords': 'Python'})
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 123, in execute
    self.error_check()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 193, in error_check
    estr = self.error()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 305, in error
    error_array.extend(self._get_resp_body_errors())
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/shopping/__init__.py", line 188, in _get_resp_body_errors
    dom = self.response.dom()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/response.py", line 229, in dom
    return self._dom
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/response.py", line 216, in __getattr__
    return getattr(self._obj, name)
AttributeError: 'Response' object has no attribute '_dom'
andymcblane commented 10 years ago

I'm getting this too :/

OP, did you get it working?

timotheus commented 10 years ago

Hi - You have the wrong sandbox domain defined, which in turn is throwing a parse error. The correct sandbox domain for the Shopping API is open.api.sandbox.ebay.com.

I'll likely add a sandbox flag to the constructor to avoid this type of mistake. It's come up a few times with users of this sdk.

btw, here a useful endpoint page I just came across.

https://ebay.custhelp.com/app/answers/detail/a_id/429/~/what-server-url-should-i-use-when-i-make-api-calls

andymcblane commented 10 years ago

Thanks mate. Got it working.

I'm having an error with the preset example "newItem" data.

Let me jump on my computer and I'll have a look what it's throwing.

On 18 Aug 2014, at 1:41 am, "Tim Keefer" notifications@github.com wrote:

Hi - You have the wrong sandbox domain defined, which in turn is throwing a parse error. The correct sandbox domain for the Shopping API is open.api.sandbox.ebay.com.

I'll likely add a sandbox flag to the constructor to avoid this type of mistake. It's come up a few times with users of this sdk.

btw, here a useful endpoint page I just came across.

https://ebay.custhelp.com/app/answers/detail/a_id/429/~/what-server-url-should-i-use-when-i-make-api-calls

— Reply to this email directly or view it on GitHub.

reverie commented 10 years ago

I'm getting this same error when not specifying a sandbox, just using the example from the docs:

from ebaysdk.shopping import Connection as shopping
api = shopping()
api.execute('findItemsAdvanced', {'keywords': 'legos'})

-> AttributeError: 'Response' object has no attribute '_dom'

andymcblane commented 10 years ago

I was using the sandbox key, you need to use the other one. :-)

On 1 Oct 2014, at 3:51 am, "Andrew Badr" notifications@github.com wrote:

I'm getting this same error when not specifying a sandbox, just using the example from the docs: from ebaysdk.shopping import Connection as shopping api = shopping() api.execute('findItemsAdvanced', {'keywords': 'legos'})

-> AttributeError: 'Response' object has no attribute '_dom'

— Reply to this email directly or view it on GitHub.

reverie commented 10 years ago

@andymcb1 So the shopping api defaults to the sandbox, but the trading api defaults to production? I'm a bit confused.

leeclemmer commented 10 years ago

I had the same error, figured it out, it is reeeally stupid. The different ebay APIs use different function call capitalization. For example, this is a call for finding API: findItemsByProduct, where you specify a productId. Notice that the first letters are not capitalized, and neither is the 'd' in the 'Id'. It's different for the shopping API however, this is what we have there (for example): GetSingleItem, which takes ItemID. Notice the different capitalization. I was calling Shopping API with getSingleItem and itemId, and this was causing the AttributeError. Arggh ]:<

FintanH commented 7 years ago

Is there a reason this error would appear spontaneously? I had a script running using the API for a few days and then this suddenly appeared.

timotheus commented 7 years ago

@FintanH can you share the error? (enable debug and send the entire request/response)

FintanH commented 7 years ago

@timotheus: I'll do my best. As I said it was spontaneous in its appearance, 99.99% of the time it works perfectly and was very unexpected.

FintanH commented 7 years ago

@timotheus I have an example request that bombed out with the AttributeError but subsequently was able to retrieve the item.

from ebaysdk.shopping import Connection as Shopping

pars = {"ItemID": "162389043741", "version": 981, "IncludeSelector": "Variations"}
r = Shopping(appid=myappid, config_file=None).execute('GetSingleItem', pars)
print(r.dict())

Could this be something to do with the API not receiving the call for some reason?

afteriwoof commented 6 years ago

I have this error and cannot figure out a solution even with your discussion here. It works 99% of the time on my macbook but this error appears every attempt to run it on linux server. I have checked proxy settings, credentials, domain specifications, etc. but no luck. Any further ideas please?

jankins commented 5 years ago

Try to add https=True. E.g. Shopping(domain="svcs.sandbox.ebay.com", config_file="ebay.yaml", https=True)

The default one doesn't use HTTPS and it returns HTML not XML, which cause the parsing error.

codetoexplore commented 5 years ago

above solution worked for me