【发布时间】:2015-02-17 10:37:54
【问题描述】:
我正在尝试使用以下命令向服务器发布请求
this.open('someurl',{
method: 'post',
data: {
'memberId': obj.id,
'password': obj.password
},
headers: {
'Accept':'application/json',
'Content-Type':'application/json',
}
}).then(function(response){
require('utils').dump(response);
});
但是响应失败
{
"contentType": null,
"headers": [
{
"name": "Content-Length",
"value": "8008"
},
{
"name": "Server",
"value": "Jetty(8.1.8.v20121106)"
}
],
"id": 2,
"redirectURL": null,
"stage": "end",
"status": 415,
"statusText": "Unsupported Media Type",
"time": "2015-02-17T10:34:16.952Z",
"url": <someURL>,
"data": null
而等效的 CURL 命令是成功的
curl -i someurl -X POST -H Content-Type:application/json --data '{"memberId": 1234567,"password":"password"}'。
我哪里错了?
【问题讨论】:
标签: json curl phantomjs httprequest casperjs