Foxpro / Support API / Update Workspace
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lnAd_be
LOCAL lnEad07
LOCAL lnAdipisicinga
LOCAL lnFugiat_e
LOCAL lcDolorf7
LOCAL lcField
LOCAL lcOperator
LOCAL lcValue
LOCAL lcStrVal
LOCAL lcTitle
LOCAL lcActive
LOCAL lcCreated_at
LOCAL lcDefault
LOCAL lcDescription
LOCAL lcId
LOCAL lcPosition
LOCAL lnIn_f25
LOCAL lcNisid81
LOCAL lnMinim_886
LOCAL lcUpdated_at
LOCAL lcUrl
LOCAL lcApp_installation
LOCAL lcCategories
LOCAL lcPermissions
LOCAL lcUsage_1h
LOCAL lcUsage_7d
LOCAL lcUsage_24h
LOCAL lcUsage_30d
LOCAL lnCulpa__d7
LOCAL lnAd7
LOCAL lcEsse0
LOCAL lnVeniam_f
LOCAL j
LOCAL lnCount_j
LOCAL lcActivated
LOCAL lcCreated_at
LOCAL lcDescription
LOCAL lcId
LOCAL lcPosition
LOCAL lcPrefer_workspace_app_order
LOCAL lcTicket_form_id
LOCAL lcTitle
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"
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "workspace": {
* "conditions": {
* "all": [
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* }
* ],
* "any": [
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* }
* ]
* },
* "description": "<string>",
* "macros": [
* "<number>",
* "<number>"
* ],
* "ticket_form_id": "<number>",
* "title": "<string>"
* }
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("workspace.conditions.all[0].field","<string>")
loJson.UpdateString("workspace.conditions.all[0].operator","<string>")
loJson.UpdateString("workspace.conditions.all[0].value","<string>")
loJson.UpdateString("workspace.conditions.all[1].field","<string>")
loJson.UpdateString("workspace.conditions.all[1].operator","<string>")
loJson.UpdateString("workspace.conditions.all[1].value","<string>")
loJson.UpdateString("workspace.conditions.any[0].field","<string>")
loJson.UpdateString("workspace.conditions.any[0].operator","<string>")
loJson.UpdateString("workspace.conditions.any[0].value","<string>")
loJson.UpdateString("workspace.conditions.any[1].field","<string>")
loJson.UpdateString("workspace.conditions.any[1].operator","<string>")
loJson.UpdateString("workspace.conditions.any[1].value","<string>")
loJson.UpdateString("workspace.description","<string>")
loJson.UpdateString("workspace.macros[0]","<number>")
loJson.UpdateString("workspace.macros[1]","<number>")
loJson.UpdateString("workspace.ticket_form_id","<number>")
loJson.UpdateString("workspace.title","<string>")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("Accept","application/json")
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PUT","https://example.zendesk.com/api/v2/workspaces/:workspace_id",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
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 loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "workspace": {
* "activated": "<boolean>",
* "apps": [
* {
* "ad_be": true,
* "ead07": 69455617,
* "adipisicinga": true
* },
* {
* "fugiat_e": false,
* "dolorf7": -57129708.70016649
* }
* ],
* "conditions": {
* "all": [
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* }
* ],
* "any": [
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "operator": "<string>",
* "value": "<string>"
* }
* ]
* },
* "created_at": "<dateTime>",
* "description": "<string>",
* "id": "<integer>",
* "macro_ids": [
* "<integer>",
* "<integer>"
* ],
* "macros": [
* "<integer>",
* "<integer>"
* ],
* "position": "<integer>",
* "prefer_workspace_app_order": "<boolean>",
* "selected_macros": [
* {
* "actions": [
* {
* "field": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "value": "<string>"
* }
* ],
* "title": "<string>",
* "active": "<boolean>",
* "created_at": "<dateTime>",
* "default": "<boolean>",
* "description": "<string>",
* "id": "<integer>",
* "position": "<integer>",
* "restriction": {
* "in_f25": true,
* "nisid81": "reprehenderit anim nostrud id",
* "minim_886": false
* },
* "updated_at": "<dateTime>",
* "url": "<string>",
* "app_installation": "<string>",
* "categories": "<string>",
* "permissions": "<string>",
* "usage_1h": "<integer>",
* "usage_7d": "<integer>",
* "usage_24h": "<integer>",
* "usage_30d": "<integer>"
* },
* {
* "actions": [
* {
* "field": "<string>",
* "value": "<string>"
* },
* {
* "field": "<string>",
* "value": "<string>"
* }
* ],
* "title": "<string>",
* "active": "<boolean>",
* "created_at": "<dateTime>",
* "default": "<boolean>",
* "description": "<string>",
* "id": "<integer>",
* "position": "<integer>",
* "restriction": {
* "culpa__d7": false,
* "ad7": true,
* "esse0": -82046233.9137964,
* "veniam_f": -91185504
* },
* "updated_at": "<dateTime>",
* "url": "<string>",
* "app_installation": "<string>",
* "categories": "<string>",
* "permissions": "<string>",
* "usage_1h": "<integer>",
* "usage_7d": "<integer>",
* "usage_24h": "<integer>",
* "usage_30d": "<integer>"
* }
* ],
* "ticket_form_id": "<integer>",
* "title": "<string>",
* "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
lcActivated = loJResp.StringOf("workspace.activated")
lcCreated_at = loJResp.StringOf("workspace.created_at")
lcDescription = loJResp.StringOf("workspace.description")
lcId = loJResp.StringOf("workspace.id")
lcPosition = loJResp.StringOf("workspace.position")
lcPrefer_workspace_app_order = loJResp.StringOf("workspace.prefer_workspace_app_order")
lcTicket_form_id = loJResp.StringOf("workspace.ticket_form_id")
lcTitle = loJResp.StringOf("workspace.title")
lcUpdated_at = loJResp.StringOf("workspace.updated_at")
lcV_Url = loJResp.StringOf("workspace.url")
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.apps")
DO WHILE i < lnCount_i
loJResp.I = i
lnAd_be = loJResp.BoolOf("workspace.apps[i].ad_be")
lnEad07 = loJResp.IntOf("workspace.apps[i].ead07")
lnAdipisicinga = loJResp.BoolOf("workspace.apps[i].adipisicinga")
lnFugiat_e = loJResp.BoolOf("workspace.apps[i].fugiat_e")
lcDolorf7 = loJResp.StringOf("workspace.apps[i].dolorf7")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.conditions.all")
DO WHILE i < lnCount_i
loJResp.I = i
lcField = loJResp.StringOf("workspace.conditions.all[i].field")
lcOperator = loJResp.StringOf("workspace.conditions.all[i].operator")
lcValue = loJResp.StringOf("workspace.conditions.all[i].value")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.conditions.any")
DO WHILE i < lnCount_i
loJResp.I = i
lcField = loJResp.StringOf("workspace.conditions.any[i].field")
lcOperator = loJResp.StringOf("workspace.conditions.any[i].operator")
lcValue = loJResp.StringOf("workspace.conditions.any[i].value")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.macro_ids")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("workspace.macro_ids[i]")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.macros")
DO WHILE i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("workspace.macros[i]")
i = i + 1
ENDDO
i = 0
lnCount_i = loJResp.SizeOfArray("workspace.selected_macros")
DO WHILE i < lnCount_i
loJResp.I = i
lcTitle = loJResp.StringOf("workspace.selected_macros[i].title")
lcActive = loJResp.StringOf("workspace.selected_macros[i].active")
lcCreated_at = loJResp.StringOf("workspace.selected_macros[i].created_at")
lcDefault = loJResp.StringOf("workspace.selected_macros[i].default")
lcDescription = loJResp.StringOf("workspace.selected_macros[i].description")
lcId = loJResp.StringOf("workspace.selected_macros[i].id")
lcPosition = loJResp.StringOf("workspace.selected_macros[i].position")
lnIn_f25 = loJResp.BoolOf("workspace.selected_macros[i].restriction.in_f25")
lcNisid81 = loJResp.StringOf("workspace.selected_macros[i].restriction.nisid81")
lnMinim_886 = loJResp.BoolOf("workspace.selected_macros[i].restriction.minim_886")
lcUpdated_at = loJResp.StringOf("workspace.selected_macros[i].updated_at")
lcUrl = loJResp.StringOf("workspace.selected_macros[i].url")
lcApp_installation = loJResp.StringOf("workspace.selected_macros[i].app_installation")
lcCategories = loJResp.StringOf("workspace.selected_macros[i].categories")
lcPermissions = loJResp.StringOf("workspace.selected_macros[i].permissions")
lcUsage_1h = loJResp.StringOf("workspace.selected_macros[i].usage_1h")
lcUsage_7d = loJResp.StringOf("workspace.selected_macros[i].usage_7d")
lcUsage_24h = loJResp.StringOf("workspace.selected_macros[i].usage_24h")
lcUsage_30d = loJResp.StringOf("workspace.selected_macros[i].usage_30d")
lnCulpa__d7 = loJResp.BoolOf("workspace.selected_macros[i].restriction.culpa__d7")
lnAd7 = loJResp.BoolOf("workspace.selected_macros[i].restriction.ad7")
lcEsse0 = loJResp.StringOf("workspace.selected_macros[i].restriction.esse0")
lnVeniam_f = loJResp.IntOf("workspace.selected_macros[i].restriction.veniam_f")
j = 0
lnCount_j = loJResp.SizeOfArray("workspace.selected_macros[i].actions")
DO WHILE j < lnCount_j
loJResp.J = j
lcField = loJResp.StringOf("workspace.selected_macros[i].actions[j].field")
lcValue = loJResp.StringOf("workspace.selected_macros[i].actions[j].value")
j = j + 1
ENDDO
i = i + 1
ENDDO
RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -u login:password -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"workspace": {
"conditions": {
"all": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>"
},
{
"field": "<string>",
"operator": "<string>",
"value": "<string>"
}
],
"any": [
{
"field": "<string>",
"operator": "<string>",
"value": "<string>"
},
{
"field": "<string>",
"operator": "<string>",
"value": "<string>"
}
]
},
"description": "<string>",
"macros": [
"<number>",
"<number>"
],
"ticket_form_id": "<number>",
"title": "<string>"
}
}'
https://example.zendesk.com/api/v2/workspaces/:workspace_id
Postman Collection Item JSON
{
"name": "Update Workspace",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"workspace\": {\n \"conditions\": {\n \"all\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"any\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n },\n \"description\": \"<string>\",\n \"macros\": [\n \"<number>\",\n \"<number>\"\n ],\n \"ticket_form_id\": \"<number>\",\n \"title\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"workspaces",
":workspace_id"
],
"variable": [
{
"key": "workspace_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n* Admins"
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"workspace\": {\n \"conditions\": {\n \"all\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"any\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n },\n \"description\": \"<string>\",\n \"macros\": [\n \"<number>\",\n \"<number>\"\n ],\n \"ticket_form_id\": \"<number>\",\n \"title\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"workspaces",
":workspace_id"
],
"variable": [
{
"key": "workspace_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"workspace\": {\n \"activated\": \"<boolean>\",\n \"apps\": [\n {\n \"ad_be\": true,\n \"ead07\": 69455617,\n \"adipisicinga\": true\n },\n {\n \"fugiat_e\": false,\n \"dolorf7\": -57129708.70016649\n }\n ],\n \"conditions\": {\n \"all\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"any\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n },\n \"created_at\": \"<dateTime>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"macro_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"macros\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"position\": \"<integer>\",\n \"prefer_workspace_app_order\": \"<boolean>\",\n \"selected_macros\": [\n {\n \"actions\": [\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"title\": \"<string>\",\n \"active\": \"<boolean>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"in_f25\": true,\n \"nisid81\": \"reprehenderit anim nostrud id\",\n \"minim_886\": false\n },\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"app_installation\": \"<string>\",\n \"categories\": \"<string>\",\n \"permissions\": \"<string>\",\n \"usage_1h\": \"<integer>\",\n \"usage_7d\": \"<integer>\",\n \"usage_24h\": \"<integer>\",\n \"usage_30d\": \"<integer>\"\n },\n {\n \"actions\": [\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"title\": \"<string>\",\n \"active\": \"<boolean>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"culpa__d7\": false,\n \"ad7\": true,\n \"esse0\": -82046233.9137964,\n \"veniam_f\": -91185504\n },\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"app_installation\": \"<string>\",\n \"categories\": \"<string>\",\n \"permissions\": \"<string>\",\n \"usage_1h\": \"<integer>\",\n \"usage_7d\": \"<integer>\",\n \"usage_24h\": \"<integer>\",\n \"usage_30d\": \"<integer>\"\n }\n ],\n \"ticket_form_id\": \"<integer>\",\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}