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

cURL importer cannot handle caret (^) used as an escape character #5182

Closed
vdespa opened this issue Sep 14, 2018 · 11 comments
Closed

cURL importer cannot handle caret (^) used as an escape character #5182

vdespa opened this issue Sep 14, 2018 · 11 comments

Comments

@vdespa
Copy link

vdespa commented Sep 14, 2018

Describe the bug
For some requests, copying the cURL request from Chrome and trying to import it in Postman does not work.

To Reproduce
Steps to reproduce the behavior:

  1. Click Import - Paste Raw Text
  2. Paste the following request

curl "https://trello.com/1/cards" --data-binary "^{^\^"name^\^":^\^"hello world^\^",^\^"pos^\^":65535,^\^"closed^\^":false,^\^"idLabels^\^":^[^],^\^"idMembers^\^":^[^],^\^"dateLastActivity^\^":1536871503239,^\^"idBoard^\^":^\^"5a84a94fc77d9f99cf9ecd8a^\^",^\^"idList^\^":^\^"a^\^",^\^"token^\^":^\^"a/L8nmd9rC5gyBYaBx6RVXGjHuMIRfMQS4b3p3zIhKWin8ejxTzJ5E5ERACxT2IILp^\^"^}" --compressed

The following error is displayed:
Error while importing Curl: 2 option-less arguments found. Only one is supported (the URL)

Expected behavior
Request was imported

App information (please complete the following information):

  • App Type: Native App
  • Postman Version: 6.2.5
  • OS: macOS
@Cakarena
Copy link

Has an answer been found yet?

@Cakarena
Copy link

One of our dojo members found this workaround:
The error was generated at the cURL option "--data-binary". The value for this option is input JSON file with its inherent formatting and it looks like when we copy the cURL command, the formatting characters are converted to C0 control codes such as ^[, ^, ^], ^^ etc.
So find and remove all of these caret (^) from the cURL command, then it will get imported in Postman.

@JP-from-Postman
Copy link

Same issue for following Curl:

curl -X POST \
https://this-is-an-api/api/v4/conversation/ \
-H 'Authorization: Bearer MYTOKEN' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: abc-123-abc-123' \
-H 'cache-control: no-cache' \
-d '{
"from": "+12345678901",
"metadata": {
"repliedToMessageTime": "abc-123",
"contactId": "abc-123"
},
"source": {
"sourceId": "api-name"
},
"text": "Hello World!",
"to": "+12345678901",
"callbackUrl": "https://this-is-an-api/callback",
"callbackMethod": "POST"

@abhijitkane
Copy link
Member

@JP-from-Postman The curl command in your 2nd message isn't complete.

@vdespa @Cakarena The issue seems to be that ^ is used as the escape character, which we don't support yet. We're working on a way to expose an option that'll let users select their desired escape character, but for now, manually removing the carets is the only workaround I can think of.

@abhijitkane abhijitkane changed the title Error while importing Curl: 2 option-less arguments found. Only one is supported (the URL) cURL importer cannot handle caret (^) used as an escape character Aug 17, 2019
@abhijitkane
Copy link
Member

@vdespa This request seems to send the body to the server as-is (which is different from the server response w/o the carets:

curl "https://postman-echo.com/post" --data-binary "^{^\^"name^\^":^\^"hello world^\^",^\^"pos^\^":65535,^\^"closed^\^":false,^\^"idLabels^\^":^[^],^\^"idMembers^\^":^[^],^\^"dateLastActivity^\^":1536871503239,^\^"idBoard^\^":^\^"5a84a94fc77d9f99cf9ecd8a^\^",^\^"idList^\^":^\^"a^\^",^\^"token^\^":^\^"a/L8nmd9rC5gyBYaBx6RVXGjHuMIRfMQS4b3p3zIhKWin8ejxTzJ5E5ERACxT2IILp^\^"^}" --compressed

vs

curl "https://postman-echo.com/post" --data-binary "{\"name\":\"hello world\",\"pos\":65535,\"closed\":false,\"idLabels\":[],\"idMembers\":[],\"dateLastActivity\":1536871503239,\"idBoard\":\"5a84a94fc77d9f99cf9ecd8a\",\"idList\":\"a\",\"token\":\"a/L8nmd9rC5gyBYaBx6RVXGjHuMIRfMQS4b3p3zIhKWin8ejxTzJ5E5ERACxT2IILp\"}" --compressed

What is the intended raw HTTP request from the first snippet?

@vdespa
Copy link
Author

vdespa commented Aug 21, 2019

@abhijitkane I have only the respective curl with carets. I would expect the body not to contain any carets. Does that help?

@Manimit10
Copy link

This problem occurs when you copy the cURL from your browser. in Chrome, you should select "copy as cURL (bash)". for postman you have to select the bash version of your request. If you want to paste in your cmd you should select "copy as cURL (cmd)".

@Mustafa017
Copy link

"copy as cURL (bash)". removes all the carets (^) and the request is imported without any errors

@hkaur008
Copy link

same isssue

both cURL (bash) and cURL (cmd) dont works.

@vdespa
Copy link
Author

vdespa commented Sep 22, 2020

@hkaur008 make sure you have the latest Postman version.

@arlemi
Copy link
Collaborator

arlemi commented Feb 16, 2023

This has been fixed in Postman v10.10. :D

@arlemi arlemi closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants