Sending file using Guzzle

Posted 11 months ago by ixudra

I'm trying to transform a postman request into Guzzle. Postman works fine, Guzzle is a nightmare. Probably just a minor detail but I can't seem to figure it out. Any help is appreciated.

The postman request: Request

My request so far (not working)

            $response = $this->client->post(
                '/api/whitelabel/images', [
                    'headers' => [
                        'Accept'                => 'application/json',
                        'Content-Type'          => 'multipart/form-data',
                        'Authorization'         => 'Bearer '. $userToken,
                    'multipart' => [
                            'name'     => 'myFile',
                            'contents' => file_get_contents($media->getPath()),

Path to file is correct

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.