使用GuzzleHttp向Clevertap发出POST请求 [英] POST request to Clevertap using GuzzleHttp

查看:148
本文介绍了使用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','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错误的请求响应:{状态":失败",错误":有效负载是强制性的}

Client error: POST https://api.clevertap.com/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', 'http://httpbin.org/post', [ 'body' =>'raw data' ]);

这应该返回200 OK,并进行必要的更新.

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

这篇关于使用GuzzleHttp向Clevertap发出POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆