Solved

POST DATA with IdHTTP

Posted on 2009-04-09
4
3,348 Views
Last Modified: 2013-12-14
Hi, could somebody help me with sending post data to a serveer and geting the answer?
I have this:

AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
IdHTTP1->Request->Accept="*/*";
IdHTTP1->Request->Referer="http://..................pl";
IdHTTP1->Request->ContentType="application/x-www-form-urlencoded";
Send->WriteString("postdatatobesent.......");
IdHTTP1->Post("http://...........................pl",Send);

I know it is sent, but how can I get the answer from the server?

Thanks
0
Comment
Question by:AL3X2
  • 3
4 Comments
 

Author Comment

by:AL3X2
ID: 24108736
Ok, I found something...

AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
Send->WriteString("postdata.............");
TStringStream * Receive = new TStringStream();
IdHTTP1->Post("http://..................pl",Send, Receive);
MessageBox(NULL, Receive->ReadString(10).c_str(), "Title", MB_OK);

But The MsgBox is empty. Why? What am I doing wrong?
The ReadString is supposed to read the content, right?
0
 

Accepted Solution

by:
AL3X2 earned 0 total points
ID: 24112373
I made it...

AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
TStringStream * Receive = new TStringStream();
Send->WriteString("user=XXXX"
                  "&pass=XXXXXX"
                  "&rcpt=%2B" +
                  GUI->CBX->Text +
                  GUI->TXT->Text +
                  "&text=" +
                  GUI->TXTText->Text +
                  (90 - GUI->TXTText->GetTextLen())
                  );
IdHTTP1->Post("http://xxxxxxxxxxxxxxxx.pl",Send, Receive);
MessageBox(NULL, Receive->DataString.c_str(), "Title", MB_OK);

But now, I can POST only once. Next time I click on the POST button, it will tell me "Connection closed gracefully". I know that this is good, it means that all the data was red and the socket was closed. but... How can I get rid of this?
0
 

Author Comment

by:AL3X2
ID: 24113083
Bah... I found it myself

IdHTTP1->DestroyComponents();  


Thanks for reading =)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FMX StringGrid1->Canvas->FillRect Problem 3 128
Best free Visio Editor? 2 140
Unable to start eclipse ? 17 133
Path to  STL Map header file 1 43
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now