我正在使用Laravel 5.1和Guzzlehttp 6.1向clevertap发帖请求。
$client = new \GuzzleHttp\Client(['headers' => ['X-CleverTap-Account-Id' => '**********','X-CleverTap-Passcode'=>'*************8']]);
$result = $client->request('POST','https://api.clevertap.com/1/upload',["d"=>[
"identity"=>"1189549",
"ts"=>1419421212,
"type"=>"profile",
"profileData"=>[
"Name"=>"Jack Montana",
"Email"=>"jack@gmail.com",
"Phone"=>"+14155551234",
"Gender"=>"M",
"Employed"=>"Y",
"Education"=>"Graduate",
"Married"=>"Y",
"Age"=>28,
"Customer Type"=>"Platinum",
]]]);
我得到以下错误。
客户端错误:
POST https://api.clevertap.com/1/upload
导致了错误400 Bad Request
回复:{"状态" :"失败" ,"错误" :"有效负载 是必须的"}
答案 0 :(得分:1)
就像你在标题中发送ID / Token一样,必须在HTTP请求的主体内发送有效负载。
这样的事情:
$r = $client->request('POST', 'http://httpbin.org/post', [ 'body' =>'raw data' ]);
这应该返回200 OK并进行必要的更新。