Create request with repetitive query params using httpclient

Hi All

is it possible to create request with repetitive params using httpclient extension?

I need to build query string like this:
?identifier=AAAA-4298-1240-0811-204-3&_include=Composition:subject:Patient&_include=Composition:entry:MedicationRequest

Here is my code:

$response = $client->get($baseUrl, ['identifier' => $prescriptionNumber, '_include' => 'Composition:subject:Patient', '_include' => 'Composition:entry:MedicationRequest'])
            ->send();

As a result of this code - only last _include is added to query params

Hi,

Have you tried using the “_include” value as an indexed array?

The final query string shall be: _include[]=value1&_include[]=value2

1 Like

I tried this way (and also checked it manually on remote API server) but they are ignored by the remote server if it is indexed in query string, the server process just repetitive params without indexes

When you provide $data parameter as an array it is not possible to use the same key multiple times, but you can provide $data also as a string.

1 Like