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

Postman generates cURL code with too few escaping characters on Windows #476

Closed
zulucommander opened this issue Apr 10, 2021 · 0 comments · Fixed by #478
Closed

Postman generates cURL code with too few escaping characters on Windows #476

zulucommander opened this issue Apr 10, 2021 · 0 comments · Fixed by #478

Comments

@zulucommander
Copy link

When working with a graphql endpoint I discovered an interesting bug:

A generated sample of cURL:

curl --location --request POST "http://localhost:9999/graphql" ^
--header "Content-Type: application/json" ^
--header "Accept: application/json" ^
--header "Origin: http://localhost:9999" ^
--data-raw "{\"query\":\"{\r\n  findScenes(\r\n    filter: {per_page: 0}\r\n    scene_filter: {is_missing: \\"performers\\"}){\r\n    count\r\n    scenes {\r\n      id\r\n      title\r\n      path\r\n    }\r\n  }\r\n}\",\"variables\":{}}"

caused an error "json body could not be decoded: invalid character 'p' in string escape code" indicating that there is problem with the string being passed in graphql query:

{
  findScenes(
    filter: {per_page: 0}
    scene_filter: {is_missing: "performers"}){
    count
    scenes {
      id
      title
      path
    }
  }
}

This graphql query works OK inside postman, only the generated cURL is missing additional backslashes, 1 on each side, like so: \\\"performers\\\

The following fixed cURL command works fine:

curl --location --request POST "http://localhost:9999/graphql" ^
--header "Content-Type: application/json" ^
--header "Accept: application/json" ^
--header "Origin: http://localhost:9999" ^
--data-raw "{\"query\":\"{\r\n  findScenes(\r\n    filter: {per_page: 0}\r\n    scene_filter: {is_missing: \\\"performers\\\"}){\r\n    count\r\n    scenes {\r\n      id\r\n      title\r\n      path\r\n    }\r\n  }\r\n}\",\"variables\":{}}"

Postman version: v8.2.1
OS: Windows 10
Curl binary path: C:\Windows\System32\curl.exe
Curl binary details:

curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: 2017-11-14, security patched: 2019-11-05
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
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 a pull request may close this issue.

1 participant