React Native
React Native
Send HTTPS POST with XML Body
See more HTTP Examples
Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.Chilkat React Native Downloads
import { Http, HttpResponse } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
const strXml = '<TransactionSetup xmlns="https://xyz.com"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>';
// Maybe you need other headers?
http.setRequestHeader('Accept', 'application/xml');
const resp = new HttpResponse();
try {
await http.httpStrAsync('POST', 'https://www.somewebsite.com/', strXml, 'utf-8', 'application/xml', resp);
} catch {
console.log(http.lastErrorText);
return;
}
// Examine the response status code:
console.log(`response status code = ${resp.statusCode}`);
// Examine the response body:
console.log(`response body: ${resp.bodyStr}`);
}