curl / Mailing Lists / curl-library / Single Mail


Re: Ubiquiti

From: Daniel Stenberg <>
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 -k

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

  curl -F uri=moo -F username=foobar -F password=secret -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)

Received on 2017-04-18