Loading

How to use cURL in Windows Command Prompt

게시 일자: Mar 2, 2024
단계

Summary

cURL in Windows Command Prompt is different from Mac/Linux, and cURL in Windows cannot use cURL command generated from Postman directly.
This article explains the main differences that needs to be taken care of, and a sample conversion of Linux style cURL to Windows Command Prompt Style cURL.

Difference 1 Single quotes cannot be used to create String

Double quote needs to be used to indicate a String.  Escaping a double quote requires a backslash, so a String 
'"Hello," said John.' becomes "\"Hello, \" said John." in Command Prompt.
Also, since \ is an escape character, literal backslash is \\.

Difference 2 New Line character is ^ rather than \

Sample Conversion

Mac/Linux version

curl --location --request POST 'http://hello.com/test' \
--header 'Authorization: abc' \
--header 'x-sync-publication: true' \
--form 'name="test"' \
--form 'files.custom.jar=@"/Users/sample/Documents/sample-mule-.jar"'
 

Windows Command Prompt version

curl --location --request POST "http://hello.com/test" ^
--header "Authorization: abc" ^
--header "x-sync-publication: true" ^
--form "name=\"test\"" ^
--form "files.custom.jar=@"C:\\Users\\sample\\sample-mule-.jar\""

Note: curl in PowerShell is an alias of Invoke-WebRequest and syntax is completely different from cURL. Please run "Get-Help Invoke-WebRequest" in PowerShell for syntax detail.
 
Knowledge 기사 번호

001115181

 
로드 중
Salesforce Help | Article