Chilkat Online Tools

DataFlex / Support API / Create Ticket Form

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sAliqua6
    String sLorem_d
    Integer iMollit_cf
    String sUllamco_f7
    String sConsequate_
    Integer iConsectetur_00
    String sLaborum50
    Boolean iIrure__c
    String sExcepteur_38
    String sSunt_8
    String sNulla_48
    String sUllamco_f6
    String sStrVal
    String sName
    String sActive
    String sCreated_at
    String sDefault
    String sDisplay_name
    String sEnd_user_visible
    String sId
    String sIn_all_brands
    String sPosition
    String sRaw_display_name
    String sRaw_name
    String sUpdated_at
    String sV_Url
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

    // 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

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "login"
    Set ComPassword Of hoHttp To "password"

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get ComQuickRequest Of hoHttp "POST" "https://example.zendesk.com/api/v2/ticket_forms" To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    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 ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    // {
    //   "ticket_form": {
    //     "name": "<string>",
    //     "active": "<boolean>",
    //     "agent_conditions": [
    //       {
    //         "aliqua6": "proident deserunt",
    //         "Lorem_d": "cillum dolor Excepteur ut",
    //         "mollit_cf": -33059877,
    //         "ullamco_f7": "dolore occaeca"
    //       },
    //       {
    //         "consequate_": 29214347.18513973,
    //         "consectetur_00": 83697330,
    //         "laborum50": "cillum Ut"
    //       }
    //     ],
    //     "created_at": "<dateTime>",
    //     "default": "<boolean>",
    //     "display_name": "<string>",
    //     "end_user_conditions": [
    //       {
    //         "irure__c": false,
    //         "Excepteur_38": -15203265.607602075,
    //         "sunt_8": "culpa laboris Ut"
    //       },
    //       {
    //         "nulla_48": "quis esse",
    //         "ullamco_f6": -25516091.19614251
    //       }
    //     ],
    //     "end_user_visible": "<boolean>",
    //     "id": "<integer>",
    //     "in_all_brands": "<boolean>",
    //     "position": "<integer>",
    //     "raw_display_name": "<string>",
    //     "raw_name": "<string>",
    //     "restricted_brand_ids": [
    //       "<integer>",
    //       "<integer>"
    //     ],
    //     "ticket_field_ids": [
    //       "<integer>",
    //       "<integer>"
    //     ],
    //     "updated_at": "<dateTime>",
    //     "url": "<string>"
    //   }
    // }

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

    Get ComStringOf Of hoJResp "ticket_form.name" To sName
    Get ComStringOf Of hoJResp "ticket_form.active" To sActive
    Get ComStringOf Of hoJResp "ticket_form.created_at" To sCreated_at
    Get ComStringOf Of hoJResp "ticket_form.default" To sDefault
    Get ComStringOf Of hoJResp "ticket_form.display_name" To sDisplay_name
    Get ComStringOf Of hoJResp "ticket_form.end_user_visible" To sEnd_user_visible
    Get ComStringOf Of hoJResp "ticket_form.id" To sId
    Get ComStringOf Of hoJResp "ticket_form.in_all_brands" To sIn_all_brands
    Get ComStringOf Of hoJResp "ticket_form.position" To sPosition
    Get ComStringOf Of hoJResp "ticket_form.raw_display_name" To sRaw_display_name
    Get ComStringOf Of hoJResp "ticket_form.raw_name" To sRaw_name
    Get ComStringOf Of hoJResp "ticket_form.updated_at" To sUpdated_at
    Get ComStringOf Of hoJResp "ticket_form.url" To sV_Url
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "ticket_form.agent_conditions" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "ticket_form.agent_conditions[i].aliqua6" To sAliqua6
        Get ComStringOf Of hoJResp "ticket_form.agent_conditions[i].Lorem_d" To sLorem_d
        Get ComIntOf Of hoJResp "ticket_form.agent_conditions[i].mollit_cf" To iMollit_cf
        Get ComStringOf Of hoJResp "ticket_form.agent_conditions[i].ullamco_f7" To sUllamco_f7
        Get ComStringOf Of hoJResp "ticket_form.agent_conditions[i].consequate_" To sConsequate_
        Get ComIntOf Of hoJResp "ticket_form.agent_conditions[i].consectetur_00" To iConsectetur_00
        Get ComStringOf Of hoJResp "ticket_form.agent_conditions[i].laborum50" To sLaborum50
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "ticket_form.end_user_conditions" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComBoolOf Of hoJResp "ticket_form.end_user_conditions[i].irure__c" To iIrure__c
        Get ComStringOf Of hoJResp "ticket_form.end_user_conditions[i].Excepteur_38" To sExcepteur_38
        Get ComStringOf Of hoJResp "ticket_form.end_user_conditions[i].sunt_8" To sSunt_8
        Get ComStringOf Of hoJResp "ticket_form.end_user_conditions[i].nulla_48" To sNulla_48
        Get ComStringOf Of hoJResp "ticket_form.end_user_conditions[i].ullamco_f6" To sUllamco_f6
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "ticket_form.restricted_brand_ids" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "ticket_form.restricted_brand_ids[i]" To sStrVal
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "ticket_form.ticket_field_ids" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "ticket_form.ticket_field_ids[i]" To sStrVal
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl  -u login:password -X POST
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms

Postman Collection Item JSON

{
  "name": "Create Ticket Form",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_forms",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_forms"
      ]
    },
    "description": "#### Allowed For\n\n* Admins\n"
  },
  "response": [
    {
      "name": "Created response",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/ticket_forms",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_forms"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"ticket_form\": {\n    \"name\": \"<string>\",\n    \"active\": \"<boolean>\",\n    \"agent_conditions\": [\n      {\n        \"aliqua6\": \"proident deserunt\",\n        \"Lorem_d\": \"cillum dolor Excepteur ut\",\n        \"mollit_cf\": -33059877,\n        \"ullamco_f7\": \"dolore occaeca\"\n      },\n      {\n        \"consequate_\": 29214347.18513973,\n        \"consectetur_00\": 83697330,\n        \"laborum50\": \"cillum Ut\"\n      }\n    ],\n    \"created_at\": \"<dateTime>\",\n    \"default\": \"<boolean>\",\n    \"display_name\": \"<string>\",\n    \"end_user_conditions\": [\n      {\n        \"irure__c\": false,\n        \"Excepteur_38\": -15203265.607602075,\n        \"sunt_8\": \"culpa laboris Ut\"\n      },\n      {\n        \"nulla_48\": \"quis esse\",\n        \"ullamco_f6\": -25516091.19614251\n      }\n    ],\n    \"end_user_visible\": \"<boolean>\",\n    \"id\": \"<integer>\",\n    \"in_all_brands\": \"<boolean>\",\n    \"position\": \"<integer>\",\n    \"raw_display_name\": \"<string>\",\n    \"raw_name\": \"<string>\",\n    \"restricted_brand_ids\": [\n      \"<integer>\",\n      \"<integer>\"\n    ],\n    \"ticket_field_ids\": [\n      \"<integer>\",\n      \"<integer>\"\n    ],\n    \"updated_at\": \"<dateTime>\",\n    \"url\": \"<string>\"\n  }\n}"
    }
  ]
}