cURL / Mailing Lists / curl-library / Single Mail


Logging in from a POST method form

From: Donnell Connally <>
Date: Mon, 25 Feb 2013 13:45:28 -0500

Hello all. I stumbled over libcURL as I was attempting to find me a
suitable replacement in C++ for Mechanize in Python as I much more enjoy
programming in the C languages than in Python (simply because C++ was my
first programming language.) I'm having a bit of trouble with the curl
post option as I'm trying to test login into my account on
Simply setting CURLOPT_URL to "" and the rest of my
options works fine and returns the code of the page, but if I set
CURLOPT_POSTFIELDS, it returns a bad request (400.) If I set
CURLOPT_POSTFIELDS and then set CURLOPT_POST to 0 (so that it should
fill in the form but not submit it (correct me if I'm wrong),) it
returns the correct code of the page, but the form is not filled. The
fields are url encoded. This is my current code. What could be wrong?

string link = "";
     string htmlCode;
     string url;
     string postData =

     CURL* c;


     c = curl_easy_init();
     curl_easy_setopt(c,CURLOPT_WRITEDATA,(void *)&htmlCode);
     curl_easy_setopt(c,CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1;
rv:15.0) Gecko/20100101 Firefox/13.0.1");

     if (curl_easy_perform(c) != 0)
         cout << "Curl Error";

List admin:
Received on 2013-02-25