Chilkat Online Tools

Foxpro / Support API / Create Ticket Form

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcAliqua6
LOCAL lcLorem_d
LOCAL lnMollit_cf
LOCAL lcUllamco_f7
LOCAL lcConsequate_
LOCAL lnConsectetur_00
LOCAL lcLaborum50
LOCAL lnIrure__c
LOCAL lcExcepteur_38
LOCAL lcSunt_8
LOCAL lcNulla_48
LOCAL lcUllamco_f6
LOCAL lcStrVal
LOCAL lcName
LOCAL lcActive
LOCAL lcCreated_at
LOCAL lcDefault
LOCAL lcDisplay_name
LOCAL lcEnd_user_visible
LOCAL lcId
LOCAL lcIn_all_brands
LOCAL lcPosition
LOCAL lcRaw_display_name
LOCAL lcRaw_name
LOCAL lcUpdated_at
LOCAL lcV_Url
LOCAL i
LOCAL lnCount_i

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

loHttp.BasicAuth = 1
loHttp.Login = "login"
loHttp.Password = "password"

loHttp.SetRequestHeader("Accept","application/json")

loResp = loHttp.QuickRequest("POST","https://example.zendesk.com/api/v2/ticket_forms")
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcName = loJResp.StringOf("ticket_form.name")
lcActive = loJResp.StringOf("ticket_form.active")
lcCreated_at = loJResp.StringOf("ticket_form.created_at")
lcDefault = loJResp.StringOf("ticket_form.default")
lcDisplay_name = loJResp.StringOf("ticket_form.display_name")
lcEnd_user_visible = loJResp.StringOf("ticket_form.end_user_visible")
lcId = loJResp.StringOf("ticket_form.id")
lcIn_all_brands = loJResp.StringOf("ticket_form.in_all_brands")
lcPosition = loJResp.StringOf("ticket_form.position")
lcRaw_display_name = loJResp.StringOf("ticket_form.raw_display_name")
lcRaw_name = loJResp.StringOf("ticket_form.raw_name")
lcUpdated_at = loJResp.StringOf("ticket_form.updated_at")
lcV_Url = loJResp.StringOf("ticket_form.url")
i = 0
lnCount_i = loJResp.SizeOfArray("ticket_form.agent_conditions")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcAliqua6 = loJResp.StringOf("ticket_form.agent_conditions[i].aliqua6")
    lcLorem_d = loJResp.StringOf("ticket_form.agent_conditions[i].Lorem_d")
    lnMollit_cf = loJResp.IntOf("ticket_form.agent_conditions[i].mollit_cf")
    lcUllamco_f7 = loJResp.StringOf("ticket_form.agent_conditions[i].ullamco_f7")
    lcConsequate_ = loJResp.StringOf("ticket_form.agent_conditions[i].consequate_")
    lnConsectetur_00 = loJResp.IntOf("ticket_form.agent_conditions[i].consectetur_00")
    lcLaborum50 = loJResp.StringOf("ticket_form.agent_conditions[i].laborum50")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ticket_form.end_user_conditions")
DO WHILE i < lnCount_i
    loJResp.I = i
    lnIrure__c = loJResp.BoolOf("ticket_form.end_user_conditions[i].irure__c")
    lcExcepteur_38 = loJResp.StringOf("ticket_form.end_user_conditions[i].Excepteur_38")
    lcSunt_8 = loJResp.StringOf("ticket_form.end_user_conditions[i].sunt_8")
    lcNulla_48 = loJResp.StringOf("ticket_form.end_user_conditions[i].nulla_48")
    lcUllamco_f6 = loJResp.StringOf("ticket_form.end_user_conditions[i].ullamco_f6")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ticket_form.restricted_brand_ids")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ticket_form.restricted_brand_ids[i]")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("ticket_form.ticket_field_ids")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcStrVal = loJResp.StringOf("ticket_form.ticket_field_ids[i]")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

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}"
    }
  ]
}