Chilkat Online Tools

autoit / Support API / Clone an already existing ticket form

Back to Collection Items

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oHttp.BasicAuth = True
$oHttp.Login = "login"
$oHttp.Password = "password"

$oHttp.SetRequestHeader "Accept","application/json"

Local $oResp = $oHttp.QuickRequest("POST","https://example.zendesk.com/api/v2/ticket_forms/:ticket_form_id/clone")
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)

    Exit
EndIf

; 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

Local $sAliqua6
Local $sLorem_d
Local $iMollit_cf
Local $sUllamco_f7
Local $sConsequate_
Local $iConsectetur_00
Local $sLaborum50
Local $bIrure__c
Local $sExcepteur_38
Local $sunt_8
Local $sNulla_48
Local $sUllamco_f6
Local $strVal

Local $sName = $oJResp.StringOf("ticket_form.name")
Local $sActive = $oJResp.StringOf("ticket_form.active")
Local $sCreated_at = $oJResp.StringOf("ticket_form.created_at")
Local $sDefault = $oJResp.StringOf("ticket_form.default")
Local $sDisplay_name = $oJResp.StringOf("ticket_form.display_name")
Local $sEnd_user_visible = $oJResp.StringOf("ticket_form.end_user_visible")
Local $sId = $oJResp.StringOf("ticket_form.id")
Local $sIn_all_brands = $oJResp.StringOf("ticket_form.in_all_brands")
Local $sPosition = $oJResp.StringOf("ticket_form.position")
Local $sRaw_display_name = $oJResp.StringOf("ticket_form.raw_display_name")
Local $sRaw_name = $oJResp.StringOf("ticket_form.raw_name")
Local $sUpdated_at = $oJResp.StringOf("ticket_form.updated_at")
Local $sV_Url = $oJResp.StringOf("ticket_form.url")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("ticket_form.agent_conditions")
While $i < $iCount_i
    $oJResp.I = $i
    $sAliqua6 = $oJResp.StringOf("ticket_form.agent_conditions[i].aliqua6")
    $sLorem_d = $oJResp.StringOf("ticket_form.agent_conditions[i].Lorem_d")
    $iMollit_cf = $oJResp.IntOf("ticket_form.agent_conditions[i].mollit_cf")
    $sUllamco_f7 = $oJResp.StringOf("ticket_form.agent_conditions[i].ullamco_f7")
    $sConsequate_ = $oJResp.StringOf("ticket_form.agent_conditions[i].consequate_")
    $iConsectetur_00 = $oJResp.IntOf("ticket_form.agent_conditions[i].consectetur_00")
    $sLaborum50 = $oJResp.StringOf("ticket_form.agent_conditions[i].laborum50")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("ticket_form.end_user_conditions")
While $i < $iCount_i
    $oJResp.I = $i
    $bIrure__c = $oJResp.BoolOf("ticket_form.end_user_conditions[i].irure__c")
    $sExcepteur_38 = $oJResp.StringOf("ticket_form.end_user_conditions[i].Excepteur_38")
    $sunt_8 = $oJResp.StringOf("ticket_form.end_user_conditions[i].sunt_8")
    $sNulla_48 = $oJResp.StringOf("ticket_form.end_user_conditions[i].nulla_48")
    $sUllamco_f6 = $oJResp.StringOf("ticket_form.end_user_conditions[i].ullamco_f6")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("ticket_form.restricted_brand_ids")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("ticket_form.restricted_brand_ids[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("ticket_form.ticket_field_ids")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("ticket_form.ticket_field_ids[i]")
    $i = $i + 1
Wend

Curl Command

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

Postman Collection Item JSON

{
  "name": "Clone an already existing ticket form",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/ticket_forms/:ticket_form_id/clone",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "ticket_forms",
        ":ticket_form_id",
        "clone"
      ],
      "variable": [
        {
          "key": "ticket_form_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "#### Allowed For\n\n* Admins\n"
  },
  "response": [
    {
      "name": "Success 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/:ticket_form_id/clone",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "ticket_forms",
            ":ticket_form_id",
            "clone"
          ],
          "variable": [
            {
              "key": "ticket_form_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_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}"
    }
  ]
}