         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: %{}}}
+        {:error, %{status: :not_found, data: %{}}, %{}}
       _ ->
         Logger.error("Could not access to trigger data of #{inspect uuid}")
-        {:error, %{status: :not_found, data: %{}}}
+        {:error, %{status: :not_found, data: %{}}, %{}}
     end
-    reply = case reply do
+
+    {:ok, reply} = case reply do
       {:ok, res, params} ->
         if params["redirect_ok"] do
-          :cowboy_req.reply(301, [
+          :cowboy_req.reply(302, [
               {"location", params["redirect_ok"]}
             ],"",req)
         else

    {:ok, reply, state}
  end

  def terminate(_reason, _req, _state) do
    :ok
  end
end

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