Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

POST DATA with IdHTTP

Posted on 2009-04-09
4
Medium Priority
?
3,579 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

722 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