           :cowboy_req.reply(200, [
               {"content-type", "application/json"}
             ],
-            json_reply,
+            String.to_charlist(json_reply),
             req
             )
         end
       {:error, res, params} ->
         if params["redirect_nok"] do
-          :cowboy_req.reply(301, [
+          :cowboy_req.reply(302, [
               {"location", params["redirect_nok"]}
-            ],"",req)
+            ],'',req)
         else
           {:ok, json_reply} = Poison.encode(res)
           :cowboy_req.reply(404, [
               {"content-type", "application/json"}
             ],
-            json_reply,
+            String.to_charlist(json_reply),
             req
             )
         end

        do_webhook_call(uuid, qsvals)
      {:ok, other_trigger} ->
        Logger.error("Try to trigger bad trigger type #{inspect uuid} / #{inspect other_trigger}", rule_uuid: uuid)
        {:error, %{status: :not_found, data: %{}}}
      _ ->
        Logger.error("Could not access to trigger data of #{inspect uuid}")
        {:error, %{status: :not_found, data: %{}}}
    end
    reply = case reply do
      {:ok, res, params} ->
        if params["redirect_ok"] do
          :cowboy_req.reply(301, [
              {"location", params["redirect_ok"]}
            ],"",req)
        else

    {:ok, reply, state}
  end

  def terminate(reason, request, state) do
    if reason != {:normal, :shutdown} do
      Logger.error("Not normal webhook termination", request: request, state: state, reason: reason)
    end
    :ok
  end
end
