I have no problem setting query parameters in Guzzle. But I can't add parameters with the same name. My query params array is below.
$query_params = array(
'test' => 'abc',
'test2' => true,
'limit' => 10,
'item_id' => '8159'
);
I want the query parameters to be as follows.
?test=abc&test2=true&limit=10&item_id=8159&item_id=333&item_id=435&item_id=123..
I want to duplicate the item_id parameter as above. And I tested as follows, but this time a bad request was returned from the service. When I looked at the link, I saw that the '=' symbols turned into strange strings like 5BD0%. There was no problem in other parameters. But that's what happened to those with the same name.
...'item_id' => array('123','3243','243')...
The guzzle setting is as follows:
$response = $this->client->request('GET', $endpoint, array(
'headers' => array(
'X-API-KEY' => KEY
),
'query' => $query_params
));
How can i fix this?
I solved above mentioned problem using Guzzle query request params.
I changed the query params as below. Then I changed the value of the guzzle 'query'.
$query_params = [
'test' => 'abc',
'test2' => true,
'limit' => 10,
'item_id' => array('8159','123')
];
$response = $this->client->request('GET', $endpoint, [
'headers' => [
'X-API-KEY' => KEY
],
'query' => Query::build($query_params)
]);