POST request to Clevertap using GuzzleHttp

回眸只為那壹抹淺笑 提交于 2021-01-28 11:26:57

问题


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','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",
      ]]]);

I am getting following Error.

Client error: POST https://api.clevertap.com/1/upload resulted in a 400 Bad Request response: { "status" : "fail" , "error" : "Payload is mandatory"}


回答1:


Just like you sent the ID/Token in the header, it is mandatory to send the payload inside the body of the HTTP request.

Something like this:

$r = $client->request('POST', 'http://httpbin.org/post', [ 'body' =>'raw data' ]);

This should return a 200 OK and do the necessary updates.



来源:https://stackoverflow.com/questions/35478213/post-request-to-clevertap-using-guzzlehttp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!