Cloudant NoSql Bluemix Content type error : bad_content_type

Cloudant NoSql Bluemix Content type error : bad_content_type

有人遇到过这个错误吗?我在 Internet 上搜索了响应,甚至写信给 IBM Cloudant 支持,但没有找到。 昨天它工作正常,但现在它不工作了。我正在使用 Zend Framework 1.12 和 Zend_Http_Client_Adapter_Curl() 函数将 POST 发送到 Cloudant 数据库。我有一个 object :

OBJECT的一部分

$obj = 
    {"articles":[
        {
        "_id":"1100_20144071226",
        "id":"1100_20144071226",
        "title":"BLA BL BADASDSDDAS A BLA Native Advertising Shakes Up Agency And Brand Ecosystem",
        "img":"http:\/\/s3.amazonaws.com\/static.mediapost.com\/publications\/images\/mp-logo-fb.jpg",
        "titleOrg":null,
        "description":"Brands such as <i class=\"highlight\">Pepsi<\/i>, Logitech,SONY, FOX, CBS, TiVo, Timberland, US Gov\'t and many more find complete, seamless satisfacting with HITVIEWS\' approach."
        },
    etc etc ... 
    ]

所以我想用函数将它发送到 curl :

$curl = new Zend_Http_Client_Adapter_Curl();
    $client = new Zend_Http_Client( $this->uri."/".$db );
    $client->setAdapter( $curl );
    $client->setMethod( Zend_Http_Client::POST );
    $client->setParameterPost("_id", $obj['id']);
    $client->setParameterPost($obj);
    $client->setHeaders('Content-type' ,'application/json');
return print $response = $client->request()->getBody();

我得到的回复是:

"error":"bad_content_type","reason":"Content-Type must be application/json"

最近有没有人在使用 Cloudant 时遇到过此类问题(昨天它运行良好)?我是否为 application/json 正确设置了 header 的 Content-Type

您似乎正确设置了页眉...我猜您发布的对象不是 JSON。尝试将 $obj 转换为 JSON.

使用以下内容代替 $client->setParameterPost($obj);

$client->setRawData(json.dumps($obj), 'application/json')