Skip to content

Commit

Permalink
fix: POST request when sending larger payloads
Browse files Browse the repository at this point in the history
Closes #214

Signed-off-by: Bruno Gaspar <[email protected]>
  • Loading branch information
brunogaspar committed Jun 16, 2022
1 parent 482671a commit 1c2923e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ public function execute($httpMethod, $url, array $parameters = [])
try {
$parameters = Utility::prepareParameters($parameters);

$response = $this->getClient()->{$httpMethod}('v1/'.$url, [ 'query' => $parameters ]);
if ($httpMethod === 'post') {
$response = $this->getClient()->post('v1/'.$url, [
'body' => $parameters,
]);
} else {
$response = $this->getClient()->{$httpMethod}('v1/'.$url, [
'query' => $parameters,
]);
}

return json_decode((string) $response->getBody(), true);
} catch (ClientException $e) {
Expand Down

0 comments on commit 1c2923e

Please sign in to comment.