简体   繁体   中英

How to assemble preemptive auth in curl command , while using POST method

I need to use POST method for a REST API.It's working perfectly in SOAP UI while i select "Preemptive Authentication" , I need to assemble this authentication option in Curl.

At Web service , preemptive properties has not set. It has only Basic authentication system with username & password.

I have tried --anyauth , it's not working. I have below command.

curl -X POST -H "content-type:application/json" --verbose -u username:password http://example.net:1234/api/Flows/UpdateStatus -d '{"EventId": "123","Status": "success"}' 

I am always getting below error.

{"Message":"Authorization has been denied for this request."}

我尝试在标头部分提供base64编码的用户名和密码值,而不是在user部分下提供用户名和密码,它为我工作了。

curl -X POST -H "content-type:application/json" --verbose -H "Authorization: Basic Base64_encoded_value_of_user_&_password" http://example.net:1234/api/Flows/UpdateStatus -d '{"EventId": "123","Status": "success"}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM