Solved

POST DATA with IdHTTP

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

775 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