你好,我想創建和問題張貼到管理平臺API藥劑:如何張貼在休息API(管理平臺)與httpotion
def createIssue(issue) do
value = %{"project_id" => 1, "subject" => "Example", "priority_id" => 1, "tracker_id" => 1}
content = Poison.Encoder.encode(value, [])
HTTPotion.post("#{url}/issues.json", [body: "issue=#{content}" , basic_auth: auth()])
end
上面的代碼的結果如下
Started POST "/issues.json" for 127.0.0.1 at 2016-06-26 11:47:25 +0200
Processing by IssuesController#create as JSON
Parameters: {"issue"=>"{\"tracker_id\":1,\"subject\":\"Example\",\"project_id\":1,\"priority_id\":1}"}
Current user: admin (id=1)
從管理平臺正確的反應應該是,據我可以瞭解以下
Parameters: {"issue"=>{"tracker_id":1,"subject": "Example","project_id":1,"priority_id":1}}
任何人都可以幫助嗎? 謝謝
你之前是否從另一種語言調用了此API?如果是,你使用了什麼代碼? – Dogbert
嘗試在'mix.exs'中添加'plug'作爲依賴項,如果您還沒有,請嘗試下面的代碼:https://gist.github.com/anonymous/e532956e00c9630b823fe4434cbe9dec我將發佈解釋爲回答它是否適合你。 – Dogbert
謝謝你,Dogbert。我試圖通過引用/不引用來做類似的事情。你的要點確實奏效!我會在您的github存儲庫中記錄您的信息,並在發佈時將您的解釋標記爲答案。謝謝 –