Chilkat Online Tools

PowerBuilder / Support API / Create Workspace

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
integer li_Ad_be
integer li_Ead07
integer li_Adipisicinga
integer li_Fugiat_e
string ls_Dolorf7
string ls_Field
string ls_Operator
string ls_Value
string ls_StrVal
string ls_Title
string ls_Active
string ls_Created_at
string ls_Default
string ls_Description
string ls_Id
string ls_Position
integer li_In_f25
string ls_Nisid81
integer li_Minim_886
string ls_Updated_at
string ls_Url
string ls_App_installation
string ls_Categories
string ls_Permissions
string ls_Usage_1h
string ls_Usage_7d
string ls_Usage_24h
string ls_Usage_30d
integer li_Culpa__d7
integer li_Ad7
string ls_Esse0
integer li_Veniam_f
integer j
integer li_Count_j
string ls_Activated
string ls_Created_at
string ls_Description
string ls_Id
string ls_Position
string ls_Prefer_workspace_app_order
string ls_Ticket_form_id
string ls_Title
string ls_Updated_at
string ls_V_Url
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.BasicAuth = 1
loo_Http.Login = "login"
loo_Http.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>"
//   }
// }

loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.UpdateString("workspace.conditions.all[0].field","<string>")
loo_Json.UpdateString("workspace.conditions.all[0].operator","<string>")
loo_Json.UpdateString("workspace.conditions.all[0].value","<string>")
loo_Json.UpdateString("workspace.conditions.all[1].field","<string>")
loo_Json.UpdateString("workspace.conditions.all[1].operator","<string>")
loo_Json.UpdateString("workspace.conditions.all[1].value","<string>")
loo_Json.UpdateString("workspace.conditions.any[0].field","<string>")
loo_Json.UpdateString("workspace.conditions.any[0].operator","<string>")
loo_Json.UpdateString("workspace.conditions.any[0].value","<string>")
loo_Json.UpdateString("workspace.conditions.any[1].field","<string>")
loo_Json.UpdateString("workspace.conditions.any[1].operator","<string>")
loo_Json.UpdateString("workspace.conditions.any[1].value","<string>")
loo_Json.UpdateString("workspace.description","<string>")
loo_Json.UpdateString("workspace.macros[0]","<number>")
loo_Json.UpdateString("workspace.macros[1]","<number>")
loo_Json.UpdateString("workspace.ticket_form_id","<number>")
loo_Json.UpdateString("workspace.title","<string>")

loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.PostJson3("https://example.zendesk.com/api/v2/workspaces","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_Json
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

ls_Activated = loo_JResp.StringOf("workspace.activated")
ls_Created_at = loo_JResp.StringOf("workspace.created_at")
ls_Description = loo_JResp.StringOf("workspace.description")
ls_Id = loo_JResp.StringOf("workspace.id")
ls_Position = loo_JResp.StringOf("workspace.position")
ls_Prefer_workspace_app_order = loo_JResp.StringOf("workspace.prefer_workspace_app_order")
ls_Ticket_form_id = loo_JResp.StringOf("workspace.ticket_form_id")
ls_Title = loo_JResp.StringOf("workspace.title")
ls_Updated_at = loo_JResp.StringOf("workspace.updated_at")
ls_V_Url = loo_JResp.StringOf("workspace.url")
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.apps")
do while i < li_Count_i
    loo_JResp.I = i
    li_Ad_be = loo_JResp.BoolOf("workspace.apps[i].ad_be")
    li_Ead07 = loo_JResp.IntOf("workspace.apps[i].ead07")
    li_Adipisicinga = loo_JResp.BoolOf("workspace.apps[i].adipisicinga")
    li_Fugiat_e = loo_JResp.BoolOf("workspace.apps[i].fugiat_e")
    ls_Dolorf7 = loo_JResp.StringOf("workspace.apps[i].dolorf7")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.conditions.all")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Field = loo_JResp.StringOf("workspace.conditions.all[i].field")
    ls_Operator = loo_JResp.StringOf("workspace.conditions.all[i].operator")
    ls_Value = loo_JResp.StringOf("workspace.conditions.all[i].value")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.conditions.any")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Field = loo_JResp.StringOf("workspace.conditions.any[i].field")
    ls_Operator = loo_JResp.StringOf("workspace.conditions.any[i].operator")
    ls_Value = loo_JResp.StringOf("workspace.conditions.any[i].value")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.macro_ids")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("workspace.macro_ids[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.macros")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("workspace.macros[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("workspace.selected_macros")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Title = loo_JResp.StringOf("workspace.selected_macros[i].title")
    ls_Active = loo_JResp.StringOf("workspace.selected_macros[i].active")
    ls_Created_at = loo_JResp.StringOf("workspace.selected_macros[i].created_at")
    ls_Default = loo_JResp.StringOf("workspace.selected_macros[i].default")
    ls_Description = loo_JResp.StringOf("workspace.selected_macros[i].description")
    ls_Id = loo_JResp.StringOf("workspace.selected_macros[i].id")
    ls_Position = loo_JResp.StringOf("workspace.selected_macros[i].position")
    li_In_f25 = loo_JResp.BoolOf("workspace.selected_macros[i].restriction.in_f25")
    ls_Nisid81 = loo_JResp.StringOf("workspace.selected_macros[i].restriction.nisid81")
    li_Minim_886 = loo_JResp.BoolOf("workspace.selected_macros[i].restriction.minim_886")
    ls_Updated_at = loo_JResp.StringOf("workspace.selected_macros[i].updated_at")
    ls_Url = loo_JResp.StringOf("workspace.selected_macros[i].url")
    ls_App_installation = loo_JResp.StringOf("workspace.selected_macros[i].app_installation")
    ls_Categories = loo_JResp.StringOf("workspace.selected_macros[i].categories")
    ls_Permissions = loo_JResp.StringOf("workspace.selected_macros[i].permissions")
    ls_Usage_1h = loo_JResp.StringOf("workspace.selected_macros[i].usage_1h")
    ls_Usage_7d = loo_JResp.StringOf("workspace.selected_macros[i].usage_7d")
    ls_Usage_24h = loo_JResp.StringOf("workspace.selected_macros[i].usage_24h")
    ls_Usage_30d = loo_JResp.StringOf("workspace.selected_macros[i].usage_30d")
    li_Culpa__d7 = loo_JResp.BoolOf("workspace.selected_macros[i].restriction.culpa__d7")
    li_Ad7 = loo_JResp.BoolOf("workspace.selected_macros[i].restriction.ad7")
    ls_Esse0 = loo_JResp.StringOf("workspace.selected_macros[i].restriction.esse0")
    li_Veniam_f = loo_JResp.IntOf("workspace.selected_macros[i].restriction.veniam_f")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("workspace.selected_macros[i].actions")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Field = loo_JResp.StringOf("workspace.selected_macros[i].actions[j].field")
        ls_Value = loo_JResp.StringOf("workspace.selected_macros[i].actions[j].value")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl  -u login:password -X POST
	-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

Postman Collection Item JSON

{
  "name": "Create Workspace",
  "request": {
    "method": "POST",
    "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",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "workspaces"
      ]
    },
    "description": "#### Allowed For\n\n* Admins\n"
  },
  "response": [
    {
      "name": "Created workspace",
      "originalRequest": {
        "method": "POST",
        "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "workspaces"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_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}"
    }
  ]
}