Im trying to do an API Call using Laravel and php. In the body of this call, I have a binary file which is of pdf format.
My code is :
/**
* @param Request $request
*/
public function transform(Request $request)
{
$pixUrl = env('PIX_TRANSFORM_FORMAT_URL');
$pixKey = env('PIX_TRANSFORM_FORMAT_API_KEY');
$file = $request->file('file');
dd($file);
$response = Http::withHeaders([
'x-api-key' => $pixKey,
'Content-Type' => 'application/pdf',
])
->attach('file', $file, 'file')
->post($pixUrl);
}
Here’s my postman call :
But as you can see, the dump returns me a null value from the file I try to request. I do need to stay with “binary” method and not “multipart/form-data”. Do you have any idea on how to resolve this ?
