I had the same problem . try to use this in the paramter that you gonna send -
$response = Http::withHeaders($this->header)
->attach('image_profile', file_get_contents($image_profile->getPathname()), $image_profile->getClientOriginalName() )
->post($this->request_host.'/api/admin/users/store', $this->transformMultiFormData($params));
private function transformMultiFormData ($data) {
$output = [];
foreach($data as $key => $value){
if(!is_array($value)){
$output[] = ['name' => $key, 'contents' => $value];
continue;
}
foreach($value as $multiKey => $multiValue){
$multiName = $key . '[' .$multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '' ) . '';
$output[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
}
}
return $output;
}
instead send the value like this -
[
"status" => "active",
"name" => "joe",
"folder" => "123",
"password" => "123456",
"email" => "joe233@gmail",
"image_profile" => "image.jpg",
"admin_info" => [
"name" => "joe",
"last_name" => "bob"
]
]
the transformMultiFormData will convert into that s -
[
["name" => "status" , "contents" => "active"],
["name" => "name" , "contents" => "joe"],
["name" => "folder" , "contents" => "123"],
["name" => "password" , "contents" => "123456"],
["name" => "email" , "contents" =>"joe233@gmail"],
[ 'name' => 'image_profile', 'contents' => 'image.jpg' ],
['name' => 'admin_info', 'contents' => [
['name' => 'name', 'contents' => "joe"],
['name' => 'last_name', 'contents' => "bob"]
]],
]
I didnt understand why , but it worked .