React Native
React Native
MYOB: Get List of Company Files
See more MYOB Examples
Gets a list of company files.Chilkat React Native Downloads
import { Http, JsonObject } 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();
http.authToken = 'ACCESS_TOKEN';
http.accept = 'application/json';
http.setRequestHeader('x-myobapi-key', 'MYOB_API_KEY');
http.setRequestHeader('x-myobapi-version', 'v2');
let strResp: string;
try {
strResp = await http.quickGetStrAsync('https://ar1.api.myob.com/accountright');
} catch {
console.log(http.lastErrorText);
return;
}
console.log(`Response Status Code: ${http.lastStatus}`);
const jsonResponse = new JsonObject();
jsonResponse.load(strResp);
jsonResponse.emitCompact = false;
console.log(jsonResponse.emit());
if (http.lastStatus !== 200) {
console.log('Failed.');
return;
}
// Sample output...
// (See the parsing code below..)
//
// Use the this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
// {
// "Id": "d2014f64-ffdf-487b-8d12-67a20976aca6",
// "Name": "Internal Sandbox API",
// "LibraryPath": "Internal Sandbox API",
// "ProductVersion": "2013.0",
// "ProductLevel": {
// "Code": 20,
// "Name": "Standard"
// },
// "CheckedOutDate": "2013-06-11T01:47:47.0065514",
// "CheckedOutBy": "developers@myob.com",
// "Uri": "{cf_uri}",
// "Country": "AU"
// }
//
const id = jsonResponse.stringOf('Id');
const name = jsonResponse.stringOf('Name');
const libraryPath = jsonResponse.stringOf('LibraryPath');
const productVersion = jsonResponse.stringOf('ProductVersion');
const productLevelCode = jsonResponse.intOf('ProductLevel.Code');
const productLevelName = jsonResponse.stringOf('ProductLevel.Name');
const checkedOutDate = jsonResponse.stringOf('CheckedOutDate');
const checkedOutBy = jsonResponse.stringOf('CheckedOutBy');
const uri = jsonResponse.stringOf('Uri');
const country = jsonResponse.stringOf('Country');
}