php - Laravel posting base64 file via HTTP client is not working
one text
I'm implementing third party API in Laravel where I have to send some data along with fileData with base64.
Like this:
To post the data I'm sending like this:
$requestUrl = $this->baseUrl . $endpoint;
$content = [
'associatedType' => 'property',
'associatedId' => 'XXXXXXX81',
'typeId' => 'DET',
'name' => '304-Smithson-Road-Details.pdf',
"isPrivate" => false,
'fileData' => 'data:application/pdf;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='
];
$response = Http::withHeaders([
"api-version" => config("apiVersion"),
"customer" => config("customer"),
"Accept" => "application/json-patch+json",
"Authorization" => "Bearer {$this->token}"
])->send($method, $requestUrl, [
"body" => json_encode($content)
])->collect()->toArray();
return $response;
After executing the above code I'm getting null response and file is not uploaded.
Is there any mistake in HTTP request code?
Source