React Native Requires Chilkat v11.0.0+
React Native
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat React Native Downloads
import { FileAccess, Http, HttpResponse } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
const fac = new FileAccess();
const reqBody = fac.readEntireFile('qa_data/pdf/helloWorld.pdf');
const resp = new HttpResponse();
try {
await http.httpBinaryAsync('POST', 'https://example.com/something', reqBody, 'application/pdf', resp);
} catch {
console.log(http.lastErrorText);
return;
}
const 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);
}