如何使用 casper.open() post JSON 向服务器发送对象?

How to post JSON object to server using casper.open()?

我正在尝试 POST 使用以下

请求服务器
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"}'.

我哪里错了?

如果您已经在您的机器上使用 npm 或 brew 安装。不起作用。您需要从源代码编译 casperjs 才能使其工作。我没有参考资料,但我也是从一个论坛上读到的。