如何curl --data "{\"obj\" : \"1234556\"}" --digest "https://USERNAME:PASSWORD@www.someurl.com/rest-api/v0/objectpost"
使用节点的请求包执行正确返回预期值的 cURL shell 命令?我尝试了这些帖子选项,但没有成功:
var request = require('request');
var body = {"obj" : "1234556"};
var post_options = {
url: url,
method: 'POST',
auth: {
'user': 'USERNAME',
'pass': 'PASSWORD',
'sendImmediately': false
},
headers: {
'Content-Type': 'text/json',
'Content-Length': JSON.stringify(body).length,
'Accept': "text/json",
'Cache-Control': "no-cache",
'Pragma': "no-cache"
},
timeout: 4500000,
body: JSON.stringify(body)
}
request(post_options, callback);
这样身体就不会被解析(得到类似的东西missing required parameter: "obj"
),我不明白这是编码问题还是只是将它传递到错误的地方(即不应该是身体)。有什么建议吗?