Skip to content

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

@mjuenema

Description

@mjuenema

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions