From 9211d636186eee6bb1154bb377542d02e2345654 Mon Sep 17 00:00:00 2001 From: Zain ul abidin Date: Mon, 2 Oct 2017 22:19:23 +1030 Subject: [PATCH] work around bad request error message https://github.com/Morning-Train/toggl-api/issues/10 do not send body option unless you have body contents --- src/TogglApi.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TogglApi.php b/src/TogglApi.php index 32508ee..8dba214 100644 --- a/src/TogglApi.php +++ b/src/TogglApi.php @@ -32,7 +32,13 @@ public function __construct($api_token) private function GET($endpoint, $body = array(), $query = array()) { - $response = $this->client->get($endpoint, ['body' => json_encode($body), 'query' => $query]); + $options = [ + 'query' => $query, + ]; + if ($body){ + $options['body'] = json_encode($body); + } + $response = $this->client->get($endpoint, $options); return $this->checkResponse($response); }