Foxpro / Support API / Create Group
Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcName
LOCAL lcCreated_at
LOCAL lcDefault
LOCAL lcDeleted
LOCAL lcDescription
LOCAL lcId
LOCAL lcIs_public
LOCAL lcUpdated_at
LOCAL lcV_Url
* 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/groups")
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)
* {
* "group": {
* "name": "<string>",
* "created_at": "<dateTime>",
* "default": "<boolean>",
* "deleted": "<boolean>",
* "description": "<string>",
* "id": "<integer>",
* "is_public": "<boolean>",
* "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("group.name")
lcCreated_at = loJResp.StringOf("group.created_at")
lcDefault = loJResp.StringOf("group.default")
lcDeleted = loJResp.StringOf("group.deleted")
lcDescription = loJResp.StringOf("group.description")
lcId = loJResp.StringOf("group.id")
lcIs_public = loJResp.StringOf("group.is_public")
lcUpdated_at = loJResp.StringOf("group.updated_at")
lcV_Url = loJResp.StringOf("group.url")
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -u login:password -X POST
-H "Accept: application/json"
https://example.zendesk.com/api/v2/groups
Postman Collection Item JSON
{
"name": "Create Group",
"request": {
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/groups",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"groups"
]
},
"description": "#### Allowed For\n\n* Admins\n* Agents assigned to a custom role with permissions to manage groups (Enterprise only)\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/groups",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"groups"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"group\": {\n \"name\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"deleted\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"is_public\": \"<boolean>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}