Solved

POST DATA with IdHTTP

Posted on 2009-04-09
4
3,311 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

  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 …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

757 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

23 Experts available now in Live!

Get 1:1 Help Now