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

Cannot pass 'body' or 'headers' key as a POST parameter #64

Open
huynq2007 opened this issue Jun 17, 2019 · 2 comments
Open

Cannot pass 'body' or 'headers' key as a POST parameter #64

huynq2007 opened this issue Jun 17, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@huynq2007
Copy link

huynq2007 commented Jun 17, 2019

The below code is from base.py

def post(self, url, body=None, headers=None, **params):
    headers = headers or {}
    url += self.urlencode(params)
    if 'content-type' not in headers:
        headers['content-type'] = 'application/json'
    return self.request('POST', url, body, headers)

the params dictionary cannot contain body key or a headers key. As the below example, I want to pass body='body of message' as a param to the Api

some_object = {'foo': 'bar'}
client.rooms.message.post(body=some_object, tags="social devcon", body="body of message")

as the body is referenced as body of POST method. Is there any way to pass body as a parameter

@huynq2007
Copy link
Author

huynq2007 commented Jun 19, 2019

some Api does have body as a query parameters.
It' better to change request body data to bodyData.

I created a pr at #65

@gene1wood
Copy link
Collaborator

The problem with the body name collision is a design problem with agithub and we likely need to fix at a fundamental level.

I can imagine doing this either with a backwards incompatible design change that leaves support for legacy deployments or a configuration to enable a user to set the name of the body variable in their code to avoid collisions.

@gene1wood gene1wood added the bug Something isn't working label Oct 7, 2019
@gene1wood gene1wood changed the title Cannot pass 'body' key as a POST paramter Cannot pass 'body' or 'header' key as a POST parameter Oct 7, 2019
@gene1wood gene1wood changed the title Cannot pass 'body' or 'header' key as a POST parameter Cannot pass 'body' or 'headers' key as a POST parameter Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants