I would like to translate a POST Request test from Postman to curl on Windows!
note: ip
, username
, password
are illustrative for this question!
Consuming from Postman, I get 200 OK Code
fine!
But, Trying to use curl from cmd is not working!
Checking on Postman the curl code
I was trying on Powershell
curl --location --request POST 'http://10.31.7.52/BdN_SMS_CXP/api/SendSMS' --header 'Authorization: Basic bWFyaWVsYTpZMFMkaSRfViZTLjQwNio=' --header 'Content-Type: application/json' --data-raw '{"ANI" : 3007209820}'
curl --location --request POST 'http://10.31.7.52/BdN_SMS_CXP/api/SendSMS' --header 'Authorization: Basic bWFyaWVsYTpZMFMkaSRfViZTLjQwNio=' --header 'Content-Type: application/json' --data-raw '{"ANI" : 3007209820}'
checking codification/decodification is fine.
Now directly with user and password, according to https://stackoverflow.com/a/27442239/811293
curl --location --request POST 'http://10.31.7.52/BdN_SMS_CXP/api/SendSMS' --user 'mariela:Y0S$i$_V&S.406*' --header 'Content-Type: application/json' --data-raw '{"ANI" : 3007209820}'
Here my results.
When I use curl
of mingw64
7.71.1 version
, the command is misinterpreted, because I get a 407 error
, Authentication required
. It's not just a powershell problem solved with Remove-item alias:curl.
I suspect you should escape some characters, and use double commas "
instead of single commas '
.
What considerations should I have with $
, _
, &
, .
and *
characters (if I should have it with any)?
How should I write the request in powershell (or mingw64 curl) for it to work?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…