DataFlex
DataFlex
MYOB: Get List of Company Files
See more MYOB Examples
Gets a list of company files.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
String sStrResp
Handle hoJsonResponse
Boolean iSuccess
String sId
String sName
String sLibraryPath
String sProductVersion
Integer iProductLevelCode
String sProductLevelName
String sCheckedOutDate
String sCheckedOutBy
String sUri
String sCountry
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComAuthToken Of hoHttp To "ACCESS_TOKEN"
Set ComAccept Of hoHttp To "application/json"
Send ComSetRequestHeader To hoHttp "x-myobapi-key" "MYOB_API_KEY"
Send ComSetRequestHeader To hoHttp "x-myobapi-version" "v2"
Get ComQuickGetStr Of hoHttp "https://ar1.api.myob.com/accountright" To sStrResp
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLastStatus Of hoHttp To iTemp1
Showln "Response Status Code: " iTemp1
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
If (Not(IsComObjectCreated(hoJsonResponse))) Begin
Send CreateComObject of hoJsonResponse
End
Get ComLoad Of hoJsonResponse sStrResp To iSuccess
Set ComEmitCompact Of hoJsonResponse To False
Get ComEmit Of hoJsonResponse To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iTemp1
If (iTemp1 <> 200) Begin
Showln "Failed."
Procedure_Return
End
// 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"
// }
//
Get ComStringOf Of hoJsonResponse "Id" To sId
Get ComStringOf Of hoJsonResponse "Name" To sName
Get ComStringOf Of hoJsonResponse "LibraryPath" To sLibraryPath
Get ComStringOf Of hoJsonResponse "ProductVersion" To sProductVersion
Get ComIntOf Of hoJsonResponse "ProductLevel.Code" To iProductLevelCode
Get ComStringOf Of hoJsonResponse "ProductLevel.Name" To sProductLevelName
Get ComStringOf Of hoJsonResponse "CheckedOutDate" To sCheckedOutDate
Get ComStringOf Of hoJsonResponse "CheckedOutBy" To sCheckedOutBy
Get ComStringOf Of hoJsonResponse "Uri" To sUri
Get ComStringOf Of hoJsonResponse "Country" To sCountry
End_Procedure