I have a curl request like below I’m trying to convert it to guzzle but when I send a request to cloudflare it keeps returning me an error. "decoding error" Is there a bug in my guzzle request? Normal curl request should be stable.
`curl
-X POST
-d '{"url":"https://storage.googleapis.com/zaid-test/Watermarks%20Demo/cf-ad-original.mp4","meta":{"name":"My First Stream Video"}}'
-H "Authorization: Bearer <API_TOKEN>"
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/stream/copy`
My codes are available below.
$response = $client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/' . $accountId . '/stream/copy', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
],
'form_params' => [
"url" => "https://storage.googleapis.com/zaid-test/Watermarks%20Demo/cf-ad-original.mp4",
"meta" => [
"name": "My First Stream Video"
]
]
3
Answers
This is how I found the solution. If anyone has problems, they can use this.
Try setting the content type header as well.
This answer is using Laravel’s HTTP request.
Also, check this amazing tool owned by Shift
https://laravelshift.com/convert-curl-to-http