I have the following function in one module:
def create_chart(data) do
url = "https://quickchart.io/chart/create"
case HTTPoison.post!(
url,
data,
[
{"Content-Type", "application/json"}
],
hackney: [:insecure]
) do
{:ok, response} -> return_url(response)
{:error, reason} -> IO.inspect(reason)
end
end
This gets called at the end after I collect a bunch of data from JIRA. The data from JIRA comes from this method in a different module. This method gets called many times before generating the graph above (see previous code).
def get(url) do
{:ok, response} = HTTPoison.get(url, [auth()], hackney: [:insecure, basic_auth: auth()])
response.body
end
Once I collect the data and called QuickChart, I get very weird behaviour while calling the QuickChart API:
** (MatchError) no match of right hand side value: {:error, {:unexpected_token, "<!DOCTYPE html><html lang=\"en\"><head><title>Oops, you've found a dead link. - JIRA</title>....</html>"}}
(km 0.1.0) lib/charts_api.ex:41: KM.Charts.Api.return_url/1
I've omitted the response for brevity, but what's happening is that instead of calling https://quickchart.io/chart/create
, it's calling http://myjirasubdomain.atlassian.net/chart/create
When I remove all calls to JIRA and hardcode the data for QuickChart, it works fine. So there's something about the "previous" JIRA calls that's affecting the endpoint base when calling QuickChart.
I'm not sure why this is happening. Any help is appreciated.