From 5b9100472646b42f88d1afcad32fdbab60107d05 Mon Sep 17 00:00:00 2001 From: Juan Snyman Date: Thu, 23 Nov 2017 17:43:40 +0200 Subject: [PATCH] Fixed bug caused by calling Poison.encode! on an empty request body --- lib/togglex.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/togglex.ex b/lib/togglex.ex index e21b152..fe3a6c7 100644 --- a/lib/togglex.ex +++ b/lib/togglex.ex @@ -52,7 +52,8 @@ defmodule Togglex do end def json_request(method, url, body \\ "", headers \\ [], options \\ []) do - request!(method, url, Poison.encode!(body), headers, options) |> process_response + body = if String.trim(body) == "", do: body, else: Poison.encode!(body) + request!(method, url, body, headers, options) |> process_response end @spec authorization_header(Client.auth, list) :: list