使用GuzzleHttp向Clevertap发出POST请求

编程入门 行业动态 更新时间:2024-10-27 07:17:31
本文介绍了使用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请求

本文发布于:2023-10-09 18:51:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GuzzleHttp   Clevertap   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!