如何在curl命令中组装抢占式身份验证,同时使用POST方法

问题描述 投票:0回答:1

我需要对 REST API 使用 POST 方法。当我选择“抢先身份验证”时,它在 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."}
rest curl soapui
1个回答
1
投票

我尝试提供用户/密码的 Base64 编码值作为标题,而不是在用户部分下提供用户和密码,它对我有用。

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"}'
© www.soinside.com 2019 - 2024. All rights reserved.