curl - http 补丁问题 [使用 cookie 以及 usr/pwd]



我正在尝试使用 curl 更新对象。

我正在尝试两种方法:
1] 在修补程序请求
中提供 usr/pswd => 表示"警告:您只能选择一个 HTTP 请求!
2] 先保存登录 cookie 并用它来执行补丁
与 -I => 表示"警告:您只能选择一个 HTTP 请求!
没有 -I => [{"消息":"会话已过期或无效","错误代码":"INVALID_SESSION_ID"}]

以下是请求:
1] 在补丁请求中提供 usr/pswd

curl -I -H "Content-Type: application/json" -H "charset=UTF-8" -H "Accept: application/json" -X PATCH -d '{"field":"new_value"}' -D- 'https://url?un=<uname>&pw=<pwd>/<path to obj>/<key>' --trace-ascii trace.OUT
Warning: You can only select one HTTP request!

2] 先保存登录 cookie 并用它来执行补丁

curl -c cookies.txt  'https://url?un=<uname>&pw=<pwd>'    
curl -b cookies.txt -H "Content-Type: application/json" -H "charset=UTF-8" -H "Accept: application/json" -X PATCH -d '{"field":"new_value"}' -D- 'https://url/<path to obj>/<key>'  
  =>[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
curl **-I** cookies.txt -H "Content-Type: application/json" -H "charset=UTF-8" -H "Accept: application/json" -X PATCH -d '{"field":"new_value"}' -D- 'https://url/<path to obj>/<key>'  
  =>  Warning: You can only select one HTTP request!

我们有一个可以使用 UI 执行补丁的工具,我检查了 firebug 中的请求/标头,似乎我在请求中拥有所有内容。但是,我想编写此调用的脚本。

有什么建议吗?

谢谢!

"

-I"表示HEAD请求,但您指定了HTTP方法"PATCH"。Curl抱怨它不能同时做这两件事。

相关内容

最新更新