Sample code for 30+ languages & platforms
.NET Core C#

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat .NET Core C# Downloads

.NET Core C#
bool success = false;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Http http = new Chilkat.Http();

Chilkat.FileAccess fac = new Chilkat.FileAccess();

byte[] reqBody = null;
reqBody = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf");

Chilkat.HttpResponse resp = new Chilkat.HttpResponse();
success = http.HttpBinary("POST","https://example.com/something",reqBody,"application/pdf",resp);
if (success == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

int responseStatusCode = resp.StatusCode;
Debug.WriteLine("Status code: " + Convert.ToString(responseStatusCode));

// For example, if the response is XML, JSON, HTML, etc.
Debug.WriteLine("response body:");
Debug.WriteLine(resp.BodyStr);