Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Does not work with json-formatted POST-request #3

Closed
seblj opened this issue May 7, 2021 · 7 comments
Closed

Does not work with json-formatted POST-request #3

seblj opened this issue May 7, 2021 · 7 comments
Labels
good first issue Good for newcomers plenary bug Something isn't working in the plenary curl wrapper

Comments

@seblj
Copy link

seblj commented May 7, 2021

I am trying to use this to make a POST-request, but it does not work. When the request reaches the server, the body is not valid json, and is not able to be loaded with json.loads. The same thing is working with postman.

I could not manage to find out if it's this plugin or plenary that does not work. (Or if I am just doing it wrong). I managed to get it working with a GET-request.

I am trying with this request:

POST http://localhost:8000/api/login/

HEADERS {
    "Content-Type": "application/json"
}

BODY {
    "email": "test@test.com",
    "password": "test"
}
@NTBBloodbath NTBBloodbath added bug Something isn't working good first issue Good for newcomers labels May 7, 2021
@NTBBloodbath
Copy link
Member

Could you try to reproduce it by running the produced curl command manually?

curl -sSL --compress -X POST -H "Content-Type: application/json" -d "email=test@test.com" -d "password=test" http://localhost:8000/api/login/

@seblj
Copy link
Author

seblj commented May 7, 2021

I assume you meant --compressed, but it also didn't work. If I print request.body where the request is handled, it is printing this:
b'email=test@test.com&password=test'.
With postman, it is printing out this:
b'{\n "email": "test@test.com",\n "password": "test"\n}'

@NTBBloodbath
Copy link
Member

I assume you meant --compressed

Yes, I'm sorry

If I print request.body where the request is handled, it is printing this:
b'email=test@test.com&password=test'.
With postman, it is printing out this:
b'{\n "email": "test@test.com",\n "password": "test"\n}'

Thank you, that information was really useful!

It seems that it's a problem of how the body is treated in plenary, instead of rendering it as expected
-d '{"email": "test@test.com"}'.
It's getting it and then redirecting to a function that renders it as
-d "email=test@test.com".

You can see this behavior by yourself here:

I'm going to open an issue in plenary. I'll leave this issue open until I find a solution.

@NTBBloodbath NTBBloodbath added plenary bug Something isn't working in the plenary curl wrapper and removed bug Something isn't working labels May 7, 2021
@seblj
Copy link
Author

seblj commented May 7, 2021

Thank you!

@NTBBloodbath
Copy link
Member

Hey, I have manually implemented support for using a JSON body as I didn't have a response yet in plenary and I think it would be better not to touch the wrapper source.

Could you please try it? 🙂

@seblj
Copy link
Author

seblj commented May 8, 2021

Thank you! This solves my problem

@NTBBloodbath
Copy link
Member

I'm glad to know it, if you have any other problem, do not hesitate to report it :)

Bugs tracking automation moved this from High priority to Closed May 8, 2021
@NTBBloodbath NTBBloodbath unpinned this issue May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers plenary bug Something isn't working in the plenary curl wrapper
Projects
Status: Closed
Development

No branches or pull requests

2 participants