我在一个模块中具有以下功能:
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
在我从 JIRA 收集大量数据后,最后会调用它。来自 JIRA 的数据来自不同模块中的此方法。在生成上面的图表之前,这个方法被调用了很多次(参见前面的代码)。
def get(url) do
{:ok, response} = HTTPoison.get(url, [auth()], hackney: [:insecure, basic_auth: auth()])
response.body
end
收集数据并调用 QuickChart 后,在调用 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
为简洁起见,我省略了响应,但发生的情况是,它不是在调用https://quickchart.io/chart/create
,而是在调用http://myjirasubdomain.atlassian.net/chart/create
当我删除对 JIRA 的所有调用并对 QuickChart 的数据进行硬编码时,它工作正常。因此,在调用 QuickChart 时,“以前的”JIRA 调用会影响端点库。
我不确定为什么会这样。任何帮助表示赞赏。