I am trying to submit this form using HTTPoison
https://gist.github.com/shankardevy/6728d63eb528b3cb223a
with the below code:
HTTPoison.post!(url,{:multipart, [{"username", "user"}, {"password", "pass"}]})
However, the resulting page gives "invalid authentication". But when I try to login using the same credentials using browser, it works.
So I was wondering if I can see the raw http request by HTTPoison so that I can compare it with the raw request from browser.
If you just want to see the request, how about accessing http://httpbin.org
? It echoes back the requested information.
iex(1)> IO.puts HTTPoison.post!("http://httpbin.org/post",{:multipart, [{"username", "user"}, {"password", "pass"}]}).body
HTTPoison
uses hackney
as backend, and I have file-uploading example using hackney
in the following (Though it's somewhat different from your example, I'm posting it for your reference, as I previously struggled on finding examples about multipart).
https://github.com/parroty/excoveralls/blob/master/lib/excoveralls/poster.ex
Is there any special reason to use multipart for just sending user/password parameter by the way?
You can use the awesome ngrok tool to create a proxy for your requests, e.g.
$ ngrok example.com 8080
will spit out an URL like http://abcd1234.ngrok.com that proxies any requests sent to it to example.com port 8080. Then you can inspect the raw requests in ngrok's web monitoring UI, at http://localhost:4040. Needless to say, you will be sending all your data to a third party so do not submit any usernames and passwords you don't want to leak.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With