(C#) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Chilkat.Http http = new Chilkat.Http();
bool success;
Chilkat.FileAccess fac = new Chilkat.FileAccess();
byte[] reqBody = null;
reqBody = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf");
string responseStr = http.PostBinary("https://example.com/something",reqBody,"application/pdf",false,false);
if (http.LastMethodSuccess == false) {
Debug.WriteLine(http.LastErrorText);
return;
}
int responseStatusCode = http.LastStatus;
Debug.WriteLine("Status code: " + Convert.ToString(responseStatusCode));
// For example, if the response is XML, JSON, HTML, etc.
Debug.WriteLine("response body:");
Debug.WriteLine(responseStr);
|