Chilkat Online Tools

DataFlex / Zoho CRM REST APIs / Users

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    Variant vDate_format
    Handle hoDate_format
    String sCountry
    String sName
    String sId
    String sNotes_desc
    String sShow_right_panel
    String sBc_view
    Boolean iShow_home
    Boolean iShow_detail_view
    String sUnpin_recent_item
    String sCity
    String sSignature
    String sSort_order_preference
    String sName_format
    String sLanguage
    String sLocale
    Boolean iMicrosoft
    Boolean iPersonal_account
    Boolean iIsonline
    String sDefault_tab_group
    String sModified_ByName
    String sModified_ById
    String sStreet
    String sV_Currency
    String sAlias
    String sFont_color
    String sBackground
    String sSelected_tabFont_color
    String sSelected_tabBackground
    String sNew_background
    String sThemeBackground
    String sScreen
    String sV_Type
    String sId
    String sState
    String sFax
    String sCountry_locale
    Boolean iSandboxDeveloper
    String sFirst_name
    String sEmail
    String sReporting_To
    String sZip
    String sDecimal_separator
    String sCreated_time
    String sWebsite
    String sModified_Time
    String sTime_format
    Integer iOffset
    String sProfileName
    String sProfileId
    String sMobile
    String sLast_name
    String sTime_zone
    String sCreated_byName
    String sCreated_byId
    String sZuid
    Boolean iConfirm
    String sFull_name
    String sPhone
    String sDob
    String sStatus
    Integer j
    Integer iCount_j
    Boolean iManager
    String sName
    Integer iPer_page
    Integer iCount
    Integer iPage
    Boolean iMore_records
    Integer i
    Integer iCount_i
    String sTemp1

    // This example assumes 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

    Send ComSetRequestHeader To hoHttp "Authorization" "{{authorization-token}}"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://domain.com/crm/v2/users" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "users": [
    //     {
    //       "country": "US",
    //       "role": {
    //         "name": "CEO",
    //         "id": "738964000000015966"
    //       },
    //       "customize_info": {
    //         "notes_desc": null,
    //         "show_right_panel": null,
    //         "bc_view": null,
    //         "show_home": false,
    //         "show_detail_view": true,
    //         "unpin_recent_item": null
    //       },
    //       "city": null,
    //       "signature": null,
    //       "sort_order_preference": "First Name,Last Name",
    //       "name_format": "Salutation,First Name,Last Name",
    //       "language": "en_US",
    //       "locale": "en_US",
    //       "microsoft": false,
    //       "personal_account": false,
    //       "Isonline": false,
    //       "default_tab_group": "0",
    //       "Modified_By": {
    //         "name": "Patricia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "street": null,
    //       "Currency": "AFN",
    //       "alias": null,
    //       "theme": {
    //         "normal_tab": {
    //           "font_color": "#FFFFFF",
    //           "background": "#222222"
    //         },
    //         "selected_tab": {
    //           "font_color": "#FFFFFF",
    //           "background": "#222222"
    //         },
    //         "new_background": null,
    //         "background": "#F3F0EB",
    //         "screen": "fixed",
    //         "type": "default"
    //       },
    //       "id": "738964000000291009",
    //       "state": null,
    //       "fax": null,
    //       "country_locale": "US",
    //       "sandboxDeveloper": false,
    //       "first_name": "Patricia",
    //       "email": "patricia.b@zohocorp.com",
    //       "Reporting_To": null,
    //       "zip": null,
    //       "decimal_separator": "en_IN",
    //       "created_time": "2019-11-26T13:00:28+00:00",
    //       "website": null,
    //       "Modified_Time": "2020-10-20T13:24:46+00:00",
    //       "time_format": "hh:mm a",
    //       "offset": 0,
    //       "profile": {
    //         "name": "Administrator",
    //         "id": "738964000000015972"
    //       },
    //       "mobile": null,
    //       "last_name": "Boyle",
    //       "time_zone": "GMT",
    //       "created_by": {
    //         "name": "Patricia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "zuid": "60034346",
    //       "confirm": true,
    //       "full_name": "Patrcia Boyle",
    //       "territories": [
    //         {
    //           "manager": true,
    //           "name": "Zylker",
    //           "id": "738964000001977341"
    //         },
    //         {
    //           "manager": true,
    //           "name": "South Zone",
    //           "id": "738964000001977355"
    //         }
    //       ],
    //       "phone": "9597538144",
    //       "dob": null,
    //       "date_format": "MM/dd/yyyy",
    //       "status": "active"
    //     },
    //     {
    //       "country": "US",
    //       "role": {
    //         "name": "Manager",
    //         "id": "738964000000015969"
    //       },
    //       "city": "Austin",
    //       "sort_order_preference": "null",
    //       "language": "en_US",
    //       "locale": "en_US",
    //       "microsoft": false,
    //       "Isonline": false,
    //       "Modified_By": {
    //         "name": "Patricia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "street": "6800 Burleson Rd, Building 310, Suite 200",
    //       "Currency": "AFN",
    //       "alias": "Patricia",
    //       "id": "738964000002006002",
    //       "state": "Texas",
    //       "fax": "444-222",
    //       "country_locale": "US",
    //       "sandboxDeveloper": false,
    //       "first_name": "Patricia",
    //       "email": "Patricia@abcl.com",
    //       "Reporting_To": null,
    //       "zip": "78744",
    //       "created_time": "2021-03-31T07:38:23+00:00",
    //       "website": "www.patriciaboyle.com",
    //       "Modified_Time": "2021-03-31T07:53:02+00:00",
    //       "time_format": "hh:mm a",
    //       "offset": 19800000,
    //       "profile": {
    //         "name": "Administrator",
    //         "id": "738964000000015972"
    //       },
    //       "mobile": "9000000000",
    //       "last_name": "Boyle",
    //       "time_zone": "Asia/Kolkata",
    //       "created_by": {
    //         "name": "Patrcia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "zuid": null,
    //       "confirm": false,
    //       "full_name": "Patricia Boyle",
    //       "territories": [
    //       ],
    //       "phone": "044-71817070",
    //       "dob": "1996-02-01",
    //       "date_format": "MM/dd/yyyy",
    //       "status": "active"
    //     },
    //     {
    //       "country": null,
    //       "role": {
    //         "name": "CEO",
    //         "id": "738964000000015966"
    //       },
    //       "city": null,
    //       "sort_order_preference": "null",
    //       "language": "en_US",
    //       "locale": "en_US",
    //       "microsoft": false,
    //       "Isonline": false,
    //       "Modified_By": {
    //         "name": "Patricia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "street": null,
    //       "Currency": null,
    //       "alias": null,
    //       "id": "738964000002058003",
    //       "state": null,
    //       "fax": null,
    //       "country_locale": "US",
    //       "sandboxDeveloper": false,
    //       "first_name": "Patricia",
    //       "email": "patricia@abc.com",
    //       "Reporting_To": null,
    //       "zip": null,
    //       "created_time": "2021-04-21T08:49:48+00:00",
    //       "website": null,
    //       "Modified_Time": "2021-04-21T08:49:48+00:00",
    //       "time_format": "hh:mm a",
    //       "offset": 0,
    //       "profile": {
    //         "name": "Administrator",
    //         "id": "738964000000015972"
    //       },
    //       "mobile": null,
    //       "last_name": "Boyle",
    //       "time_zone": "GMT",
    //       "created_by": {
    //         "name": "Patricia Boyle",
    //         "id": "738964000000291009"
    //       },
    //       "zuid": null,
    //       "confirm": false,
    //       "full_name": "Patricia Boyle",
    //       "territories": [
    //       ],
    //       "phone": null,
    //       "dob": null,
    //       "date_format": "MM/dd/yyyy",
    //       "status": "active"
    //     }
    //   ],
    //   "info": {
    //     "per_page": 200,
    //     "count": 3,
    //     "page": 1,
    //     "more_records": false
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Get Create (RefClass(cComChilkatDtObj)) To hoDate_format
    If (Not(IsComObjectCreated(hoDate_format))) Begin
        Send CreateComObject of hoDate_format
    End

    Get ComIntOf Of hoJResp "info.per_page" To iPer_page
    Get ComIntOf Of hoJResp "info.count" To iCount
    Get ComIntOf Of hoJResp "info.page" To iPage
    Get ComBoolOf Of hoJResp "info.more_records" To iMore_records
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "users" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "users[i].country" To sCountry
        Get ComStringOf Of hoJResp "users[i].role.name" To sName
        Get ComStringOf Of hoJResp "users[i].role.id" To sId
        Get ComStringOf Of hoJResp "users[i].customize_info.notes_desc" To sNotes_desc
        Get ComStringOf Of hoJResp "users[i].customize_info.show_right_panel" To sShow_right_panel
        Get ComStringOf Of hoJResp "users[i].customize_info.bc_view" To sBc_view
        Get ComBoolOf Of hoJResp "users[i].customize_info.show_home" To iShow_home
        Get ComBoolOf Of hoJResp "users[i].customize_info.show_detail_view" To iShow_detail_view
        Get ComStringOf Of hoJResp "users[i].customize_info.unpin_recent_item" To sUnpin_recent_item
        Get ComStringOf Of hoJResp "users[i].city" To sCity
        Get ComStringOf Of hoJResp "users[i].signature" To sSignature
        Get ComStringOf Of hoJResp "users[i].sort_order_preference" To sSort_order_preference
        Get ComStringOf Of hoJResp "users[i].name_format" To sName_format
        Get ComStringOf Of hoJResp "users[i].language" To sLanguage
        Get ComStringOf Of hoJResp "users[i].locale" To sLocale
        Get ComBoolOf Of hoJResp "users[i].microsoft" To iMicrosoft
        Get ComBoolOf Of hoJResp "users[i].personal_account" To iPersonal_account
        Get ComBoolOf Of hoJResp "users[i].Isonline" To iIsonline
        Get ComStringOf Of hoJResp "users[i].default_tab_group" To sDefault_tab_group
        Get ComStringOf Of hoJResp "users[i].Modified_By.name" To sModified_ByName
        Get ComStringOf Of hoJResp "users[i].Modified_By.id" To sModified_ById
        Get ComStringOf Of hoJResp "users[i].street" To sStreet
        Get ComStringOf Of hoJResp "users[i].Currency" To sV_Currency
        Get ComStringOf Of hoJResp "users[i].alias" To sAlias
        Get ComStringOf Of hoJResp "users[i].theme.normal_tab.font_color" To sFont_color
        Get ComStringOf Of hoJResp "users[i].theme.normal_tab.background" To sBackground
        Get ComStringOf Of hoJResp "users[i].theme.selected_tab.font_color" To sSelected_tabFont_color
        Get ComStringOf Of hoJResp "users[i].theme.selected_tab.background" To sSelected_tabBackground
        Get ComStringOf Of hoJResp "users[i].theme.new_background" To sNew_background
        Get ComStringOf Of hoJResp "users[i].theme.background" To sThemeBackground
        Get ComStringOf Of hoJResp "users[i].theme.screen" To sScreen
        Get ComStringOf Of hoJResp "users[i].theme.type" To sV_Type
        Get ComStringOf Of hoJResp "users[i].id" To sId
        Get ComStringOf Of hoJResp "users[i].state" To sState
        Get ComStringOf Of hoJResp "users[i].fax" To sFax
        Get ComStringOf Of hoJResp "users[i].country_locale" To sCountry_locale
        Get ComBoolOf Of hoJResp "users[i].sandboxDeveloper" To iSandboxDeveloper
        Get ComStringOf Of hoJResp "users[i].first_name" To sFirst_name
        Get ComStringOf Of hoJResp "users[i].email" To sEmail
        Get ComStringOf Of hoJResp "users[i].Reporting_To" To sReporting_To
        Get ComStringOf Of hoJResp "users[i].zip" To sZip
        Get ComStringOf Of hoJResp "users[i].decimal_separator" To sDecimal_separator
        Get ComStringOf Of