Replies: 1 comment
-
Moving to discussions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
HTTP::get() request failed with array named parameters like ids[]=val. Instead I used Guzzle it works fine.
Steps To Reproduce:
Below is the sample code for HTTP::get failed scenario
$params = array(
'source_type' => $sourceType,
'source_ids[]' => $sourceIds,
'page' => $page,
'per_page' => $limit,
'types[]' => $types
);
$query = http_build_query($params, null, '&');
$path = '?' . preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
Above code will generate the URL like below
?source_type=legal_guide&source_ids[]=152361&page=5&per_page=5&types[]=question&types[]=legal_guide
The request getting failed only when I add param "source_ids[]=152361", but it works fine with "types[]"
Something with underscore in the param name or multiple array names params causing issue.
Tried below code to make request
$response = Http::withHeaders([
'Accept'=>'application/json',
])->get($this->url . $path);
or
$response = Http::withHeaders([
'Accept'=>'application/json',
])->get($this->url, $params);
Beta Was this translation helpful? Give feedback.
All reactions