body option is ignored inside Http::withOptions() #33301
Replies: 4 comments
-
I've taken a look but I don't think we already support binary file requests. I think we'd need a new method for this to work. You do have (See docs): $response = Http::attach(
'attachment', file_get_contents($photo), 'photo.jpg', ['Content-Type' => Storage::mimeType($photo)]
)->post('api/settings/profile/photo'); But I'm guessing that's not exactly what you need? |
Beta Was this translation helpful? Give feedback.
-
I tried to use this attachment method, but without success, I really need to send the binary in the request body. If it were possible to accept the body within the options it would already solve the problem. |
Beta Was this translation helpful? Give feedback.
-
PRs welcome. |
Beta Was this translation helpful? Give feedback.
-
Moving to discussions as this is more a feature request. |
Beta Was this translation helpful? Give feedback.
-
Description:
I need to make an api call, where I send a file directly in the body of the request, I can make the call normally using
Guzzle
, but when I try to use theHTTP Client
the api returns an error saying that it was unable to read the contents of the request.Steps To Reproduce:
When I make the request using the
Guzzle
client the request works correctly:However, when I try to upload the file using the
HTTP Client
, the request does not work and returns an error:I can't send the
body
attribute inside the->post('api/settings/profile/photo', $data)
method, because$data
only accepts an array.Apparently the
HTTP Client
ignores thebody
option insidewithOptions()
. Does this really occur or am I doing something wrong? I've been trying to make this work for hours, I decided to make the request usingGuzzle
just to be sure and everything worked correctly.This is the api I'm calling: https://developers.facebook.com/docs/whatsapp/api/settings/profile#setphoto
Beta Was this translation helpful? Give feedback.
All reactions