本文介绍了使用GuzzleHttp向Clevertap发出POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Laravel 5.1和Guzzlehttp 6.1向clevertap发出发布请求.
I am using Laravel 5.1 and Guzzlehttp 6.1 to make post request to clevertap.
$client = new \GuzzleHttp\Client(['headers' => ['X-CleverTap-Account-Id' => '**********','X-CleverTap-Passcode'=>'*************8']]); $result = $client->request('POST','api.clevertap/1/upload',["d"=>[ "identity"=>"1189549", "ts"=>1419421212, "type"=>"profile", "profileData"=>[ "Name"=>"Jack Montana", "Email"=>"jack@gmail", "Phone"=>"+14155551234", "Gender"=>"M", "Employed"=>"Y", "Education"=>"Graduate", "Married"=>"Y", "Age"=>28, "Customer Type"=>"Platinum", ]]]);我正在关注错误.
客户端错误: POST api.clevertap/1/upload 导致 400错误的请求响应:{状态":失败",错误":有效负载是强制性的}
Client error: POST api.clevertap/1/upload resulted in a 400 Bad Request response: { "status" : "fail" , "error" : "Payload is mandatory"}
推荐答案就像您在标头中发送ID/令牌一样,必须在HTTP请求的正文中发送有效负载.
Just like you sent the ID/Token in the header, it is mandatory to send the payload inside the body of the HTTP request.
类似这样的东西:
$r = $client->request('POST', 'httpbin/post', [ 'body' =>'raw data' ]);这应该返回200 OK,并进行必要的更新.
This should return a 200 OK and do the necessary updates.
更多推荐
使用GuzzleHttp向Clevertap发出POST请求
发布评论