This is my first try with an API and HttpWebRequest Class in Visual Studio 2008 c++. I try to POST some variables to a link and want an link value from the API back, but I get an Response (not from API) : this->t_bbcode->Text = dataStream->ToString(); // System.Net.ConnectStream
I think there is an error in my Request.
/// Request / Bitte
HttpWebRequest^ myReq = dynamic_cast<HttpWebRequest^>(WebRequest::Create( "http://linksave.in/protect?api=TRUE" ));
myReq->Timeout = 3000;
myReq->ServicePoint->Expect100Continue = false;
myReq->Method = "POST";
String^ inputData = "protect=true links=http://rapidshare.com/files/example.rar";
ASCIIEncoding^ encoding = gcnew ASCIIEncoding;
array<Byte>^ byte1 = encoding->GetBytes( inputData );
// Set the content type of the data being posted.
myReq->ContentType = "application/x-www-form-urlencoded";
// Set the content length of the String* being posted.
myReq->ContentLength = byte1->Length;
System::IO::Stream^ newStream = myReq->GetRequestStream();
newStream->Write( byte1, 0, byte1->Length );
myReq->GetRequestStream();
Console::WriteLine( "The value of 'ContentLength' property after sending the data is {0}", myReq->ContentLength );
/// Response / Antwort
HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(myReq->GetResponse());
System::IO::Stream^ dataStream = response->GetResponseStream();
this->t_bbcode->Text = dataStream->ToString();
// Close the Stream Object*.
newStream->Close();
response->Close();
Thanks :).