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

Wrong curl generation for working POST request #10581

Closed
1 task done
Ducane opened this issue Jan 18, 2022 · 2 comments · Fixed by postmanlabs/postman-code-generators#666
Closed
1 task done

Wrong curl generation for working POST request #10581

Ducane opened this issue Jan 18, 2022 · 2 comments · Fixed by postmanlabs/postman-code-generators#666

Comments

@Ducane
Copy link

Ducane commented Jan 18, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the Issue

Hello everyone,

If you create a POST Request with Content-Type: application/x-www-form-urlencoded filled with some form parameters and the response returns a 30x redirect response, then the executed postman request will work. The generated cURL command however is not working when pasted into a terminal.

E.g.

curl --location --request POST '<URL>' \
         --header 'Content-Type: application/x-www-form-urlencoded' \
         --data-urlencode 'username=<USERNAME>' \
         --data-urlencode 'password=<PASSWORD>'

is being generated. However this cURL request doesn't work in the terminal since according to this there is no need to specify --request POST if -d, --data or --data-urlencode is used. If you still specify --request POST all redirections triggered by --location are sent as POST methods (instead of the usual expected GET) which leads to unexpected behaviors.

The correct cURL looks like this:

curl --location '<URL>' \
         --header 'Content-Type: application/x-www-form-urlencoded' \
         --data-urlencode 'username=<USERNAME>' \
         --data-urlencode 'password=<PASSWORD>'

Since a user expects the cURL command to behave the same way as postman is responding i suggest removing the --request POST in the generated cURL.

Steps To Reproduce

  1. Create a POST at a resource <URL> which returns a 30x as response.
  2. Add the Request-Header Content-type: application/x-www-form-urlencoded or check the x-www-form-urlencoded radio button for the body and add some key/value pairs.
  3. Copy the generated curl and try to execute it in the terminal. It will try to call the redirects with POST as a method, which can lead to unexpected behavior.

Screenshots or Videos

No response

Environment Information

- Operating System: Mac OS
- Platform Type: 
- Postman Version: v.9.0.9

Additional Context?

No response

@dhwaneetbhatt
Copy link

@Ducane We've fixed this issue in the latest version (10.10.x). Could you update to the latest version and check if it solves your problem?

@dhwaneetbhatt
Copy link

Closing this issue as it has been fixed in version 10.10. Feel free to reopen if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment