Skip to content

Commit 5ec5966

Browse files
authored
Handle empty parameters in POST call better (#42)
PHP is encoding the empty parameters as an empty JSON list rather than the empty JSON object we need. Explicitly test for empty parameters.
1 parent e754a13 commit 5ec5966

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function apiCall($method, $path, $params, $additional_headers = [])
214214
$headers = [];
215215
if (in_array($method, ["POST", "PUT", "PATCH"], true)) {
216216
ksort($params);
217-
$body = json_encode($params);
217+
$body = empty($params) ? "{}" : json_encode($params);
218218
$params = [];
219219
$headers["Content-Type"] = "application/json";
220220
$uri = $path;

0 commit comments

Comments
 (0)