Sample code for 30+ languages & platforms
Node.js

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

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

    var http = new chilkat.Http();

    var fac = new chilkat.FileAccess();

    reqBody = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf");

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

    var responseStatusCode = resp.StatusCode;
    console.log("Status code: " + responseStatusCode);

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

}

chilkatExample();