mercredi 23 janvier 2019

Laravel - Guzzle Post Null/Empty Values

I've been trying to work with Guzzle and learn my way around it, but I'm a bit confused about using a request in conjunction with empty or null values.

For example:

    $response = $client->request('POST', 'https://www.testsite.com/coep/public/api/donations', [
        'form_params' => [
            'client' => [
                'web_id' => NULL,
                'name' => 'Test Name',
                'address1' => '123 E 45th Avenue',
                'address2' => 'Ste. 1',
                'city' => 'Nowhere',
                'state' => 'CO',
                'zip' => '80002'
            ],
            'contact' => [],
            'donation' => [
                'status_id' => 1,
                'amount' => $donation->amount,
                'balance' => $donation->balance,
                'date' => $donation->date,
                'group_id' => $group->id,
            ],
        ]
    ]);

But after running a test, I found out that 'web_id' completely disappears from my request if set to NULL, so my question is how do I ensure that it is kept around on the request to work with my conditionals?

At this point if I dd the $request->client, all I get back is everything but the web_id.

Thanks! Mica



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire