Skip to content

Pass data using 'json' so it gets encoded and correctly mimetype-d.#29

Closed
elo80ka wants to merge 1 commit intoandela-sjames:masterfrom
elo80ka:master
Closed

Pass data using 'json' so it gets encoded and correctly mimetype-d.#29
elo80ka wants to merge 1 commit intoandela-sjames:masterfrom
elo80ka:master

Conversation

@elo80ka
Copy link
Copy Markdown
Contributor

@elo80ka elo80ka commented Apr 25, 2017

Hi...thanks for releasing this.

While using the latest version (1.2.4) in a project with Python 3.6, I noticed that trying to create plans kept returning a 400: Bad Request. Specifically:

from paystackapi.paystack import Plan
params = {'name': 'Some Plan', ...}
response = Plan.create(**params)

Enabling logging for requests, I discovered that the Content-type was being set to application/x-www-urlencoded, and the data posted as key/value pairs, which Paystack doesn't support. This appears to be the default behaviour for requests.

Changing the data parameter in paystackapi.base.PaystackRequests._request to json works (it correctly sets the Content-type to application/json and JSON-encodes the payload), and has been supported since version 2.4.2. I'm a bit confused though - is this a Python 3.6-only issue? Or are you manually JSON-encoding your data somehow?

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 948bbd9 on elo80ka:master into ** on andela-sjames:master**.

@andela-sjames
Copy link
Copy Markdown
Owner

@elo80ka thanks for reaching out, this is a better modification as opposed to encoding it manually. Please, can you raise a Pull request to the Develop branch so that it can be merged and updated

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

Successfully merging this pull request may close these issues.

3 participants