[英]How to assemble preemptive auth in curl command , while using POST method
我需要對REST API使用POST方法。當我選擇“ Preemptive Authentication”時,它在SOAP UI中運行良好,我需要在Curl中組裝此身份驗證選項。
在Web服務上,沒有設置搶占屬性。 它只有帶有用戶名和密碼的基本身份驗證系統。
我試過了--anyauth,它不起作用。 我有以下命令。
curl -X POST -H "content-type:application/json" --verbose -u username:password http://example.net:1234/api/Flows/UpdateStatus -d '{"EventId": "123","Status": "success"}'
我總是在錯誤之下。
{"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"}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.