curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Ubiquiti

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 18 Apr 2017 16:02:29 +0200 (CEST)

On Tue, 18 Apr 2017, Greg Stewart via curl-library wrote:

> The boundary value changes with each request. I tried this command from the
> command line just to see if I could get it working from there.
>
> curl -X POST -H "Content-Type: multipart/form-data;
> boundary=----------------------------8836643981898118181802691882"
> --data-binary @test.txt https://192.168.135.22/login.cgi -k

You want -F and let curl handle the boundary string by itself:

  curl -F uri=moo -F username=foobar -F password=secret
  https://192.168.135.22/login.cgi -k

Add "--trace-ascii logfile.txt" to the command line to save the entire request
and verify that it actually looks like you want it to look.

Then you *probably* want to add "--cookie-jar cookies.txt" to the command line
as well to save cookies from the response, as that is probably how it saves
the logged in session. You then use "--cookie cookies.txt" in subsequent
requests to reuse that session (you probably want to use both options since
subsequent reqests might updated the cookies as well).

Finally, when you post the login data the server often redirects you to a new
page and curl doesn't following redirects by default. Use --location for that.

(and avoid -X POST, that will only cause you grief)

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-04-18