How to properly consume an C# APi?
So far i try this:
iex(18)> url = "http://172.1.1.1/API/api/login" "http://172.16.20.143/FileServerAPI/api/login"
iex(19)> data = %{username: "testuser", password: "testpass"} %{password: "testpass", username: "testuser"}
iex(20)> postdata = URI.encode_query(data)
"password=testpass&username=testuser"
iex(21)> headers = [{"Content-Type", "application/json"}]
[{"Content-Type", "application/json"}]
But I got this error.
{:ok,
%HTTPoison.Response{body: "{\"Message\":\"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.\"}",
headers: [{"Cache-Control", "no-cache"}, {"Pragma", "no-cache"},
{"Content-Type", "application/json; charset=utf-8"}, {"Expires", "-1"},
{"Server", "Microsoft-IIS/8.5"}, {"X-AspNet-Version", "4.0.30319"},
{"X-Powered-By", "ASP.NET"}, {"Date", "Thu, 16 Mar 2017 07:06:15 GMT"},
{"Content-Length", "164"}], status_code: 415}}
Using postman, its working fine
Any Idea?