Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send list as parameter to POST request. #35

Open
mjuenema opened this issue Jun 29, 2017 · 0 comments
Open

Unable to send list as parameter to POST request. #35

mjuenema opened this issue Jun 29, 2017 · 0 comments

Comments

@mjuenema
Copy link

mjuenema commented Jun 29, 2017

The following code will fail because the current implementation expects a dictionary as the (optional) third argument to api.make_request().

params = [{'id': 1, 'enable': True},{'id': 2, 'enable': False}]
myapi.make_request('POST', '/some/path', params=params)

The full traceback is (the line numbers may be a little off because I've been editing the files).

Traceback (most recent call last):
  File "sigfoxapi.py", line 226, in <module>
    print(sigfox.callbacks('5947bc1150057463d724131c',callbacks))
  File "sigfoxapi.py", line 193, in callbacks
    self._request('POST', '/devicetypes/%s/callbacks/new' % (devicetype_id), params=callbacks)
  File "sigfoxapi.py", line 99, in _request
    resp = self.api.make_request(method, path, params=params, headers=headers)
  File "/home/mjuenemann/.virtualenvs/python-sigfox-backend-api/lib/python3.5/site-packages/drest/api.py", line 200, in make_request
    return self.request.make_request(method, url, params, headers)
  File "/home/mjuenemann/.virtualenvs/python-sigfox-backend-api/lib/python3.5/site-packages/drest/request.py", line 395, in make_request
    params = dict(self._extra_params, **params)
TypeError: type object argument after ** must be a mapping, not list

As a quick work-around I changed drest/request.py a bit but this will ignore self._extra_params.
It solves my immediate problem though.

        if isinstance(params, dict):
            params = dict(self._extra_params, **params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant