PowerBuilder / Support API / Update User
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Name
string ls_Active
string ls_Alias
string ls_Chat_only
string ls_Created_at
string ls_Custom_role_id
string ls_Default_group_id
string ls_Details
string ls_V_Email
string ls_External_id
string ls_Iana_time_zone
string ls_Id
string ls_Last_login_at
string ls_Locale
string ls_Locale_id
string ls_Moderator
string ls_Notes
string ls_Only_private_comments
string ls_Organization_id
string ls_Phone
integer li_Dolorea1
string ls_Deserunt3
string ls_Remote_photo_url
string ls_Report_csv
string ls_Restricted_agent
string ls_Role
string ls_Role_type
string ls_V_Shared
string ls_Shared_agent
string ls_Shared_phone_number
string ls_Signature
string ls_Suspended
string ls_Tags
string ls_Ticket_restriction
string ls_Time_zone
string ls_Two_factor_auth_enabled
string ls_Updated_at
string ls_V_Url
string ls_Nostrudacc
string ls_In_80e
integer li_Proident_e2
integer li_Voluptate_98
string ls_Verified
// 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.
// {
// "user": {
// "name": "<string>",
// "email": "<string>",
// "custom_role_id": "<integer>",
// "external_id": "<string>",
// "identities": [
// {
// "type": "<string>",
// "value": "<string>"
// },
// {
// "type": "<string>",
// "value": "<string>"
// }
// ],
// "organization": {
// "name": "<string>"
// },
// "organization_id": "<integer>",
// "role": "<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("user.name","<string>")
loo_Json.UpdateString("user.email","<string>")
loo_Json.UpdateString("user.custom_role_id","<integer>")
loo_Json.UpdateString("user.external_id","<string>")
loo_Json.UpdateString("user.identities[0].type","<string>")
loo_Json.UpdateString("user.identities[0].value","<string>")
loo_Json.UpdateString("user.identities[1].type","<string>")
loo_Json.UpdateString("user.identities[1].value","<string>")
loo_Json.UpdateString("user.organization.name","<string>")
loo_Json.UpdateString("user.organization_id","<integer>")
loo_Json.UpdateString("user.role","<string>")
loo_Http.SetRequestHeader("Content-Type","application/json")
loo_Http.SetRequestHeader("Accept","application/json")
loo_SbRequestBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_Resp = loo_Http.PTextSb("PUT","https://example.zendesk.com/api/v2/users/:user_id",loo_SbRequestBody,"utf-8","application/json",0,0)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
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_SbRequestBody
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)
// {
// "user": {
// "name": "<string>",
// "active": "<boolean>",
// "alias": "<string>",
// "chat_only": "<boolean>",
// "created_at": "<string>",
// "custom_role_id": "<integer>",
// "default_group_id": "<integer>",
// "details": "<string>",
// "email": "<string>",
// "external_id": "<string>",
// "iana_time_zone": "<string>",
// "id": "<integer>",
// "last_login_at": "<string>",
// "locale": "<string>",
// "locale_id": "<integer>",
// "moderator": "<boolean>",
// "notes": "<string>",
// "only_private_comments": "<boolean>",
// "organization_id": "<integer>",
// "phone": "<string>",
// "photo": {
// "dolorea1": false,
// "deserunt3": 95124319.10825741
// },
// "remote_photo_url": "<string>",
// "report_csv": "<boolean>",
// "restricted_agent": "<boolean>",
// "role": "<string>",
// "role_type": "<integer>",
// "shared": "<boolean>",
// "shared_agent": "<boolean>",
// "shared_phone_number": "<boolean>",
// "signature": "<string>",
// "suspended": "<boolean>",
// "tags": "<array>",
// "ticket_restriction": "<string>",
// "time_zone": "<string>",
// "two_factor_auth_enabled": "<boolean>",
// "updated_at": "<string>",
// "url": "<string>",
// "user_fields": {
// "nostrudacc": -12929960.546221554,
// "in_80e": 25167751.960886702,
// "proident_e2": true,
// "voluptate_98": -58995022
// },
// "verified": "<boolean>"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Name = loo_JResp.StringOf("user.name")
ls_Active = loo_JResp.StringOf("user.active")
ls_Alias = loo_JResp.StringOf("user.alias")
ls_Chat_only = loo_JResp.StringOf("user.chat_only")
ls_Created_at = loo_JResp.StringOf("user.created_at")
ls_Custom_role_id = loo_JResp.StringOf("user.custom_role_id")
ls_Default_group_id = loo_JResp.StringOf("user.default_group_id")
ls_Details = loo_JResp.StringOf("user.details")
ls_V_Email = loo_JResp.StringOf("user.email")
ls_External_id = loo_JResp.StringOf("user.external_id")
ls_Iana_time_zone = loo_JResp.StringOf("user.iana_time_zone")
ls_Id = loo_JResp.StringOf("user.id")
ls_Last_login_at = loo_JResp.StringOf("user.last_login_at")
ls_Locale = loo_JResp.StringOf("user.locale")
ls_Locale_id = loo_JResp.StringOf("user.locale_id")
ls_Moderator = loo_JResp.StringOf("user.moderator")
ls_Notes = loo_JResp.StringOf("user.notes")
ls_Only_private_comments = loo_JResp.StringOf("user.only_private_comments")
ls_Organization_id = loo_JResp.StringOf("user.organization_id")
ls_Phone = loo_JResp.StringOf("user.phone")
li_Dolorea1 = loo_JResp.BoolOf("user.photo.dolorea1")
ls_Deserunt3 = loo_JResp.StringOf("user.photo.deserunt3")
ls_Remote_photo_url = loo_JResp.StringOf("user.remote_photo_url")
ls_Report_csv = loo_JResp.StringOf("user.report_csv")
ls_Restricted_agent = loo_JResp.StringOf("user.restricted_agent")
ls_Role = loo_JResp.StringOf("user.role")
ls_Role_type = loo_JResp.StringOf("user.role_type")
ls_V_Shared = loo_JResp.StringOf("user.shared")
ls_Shared_agent = loo_JResp.StringOf("user.shared_agent")
ls_Shared_phone_number = loo_JResp.StringOf("user.shared_phone_number")
ls_Signature = loo_JResp.StringOf("user.signature")
ls_Suspended = loo_JResp.StringOf("user.suspended")
ls_Tags = loo_JResp.StringOf("user.tags")
ls_Ticket_restriction = loo_JResp.StringOf("user.ticket_restriction")
ls_Time_zone = loo_JResp.StringOf("user.time_zone")
ls_Two_factor_auth_enabled = loo_JResp.StringOf("user.two_factor_auth_enabled")
ls_Updated_at = loo_JResp.StringOf("user.updated_at")
ls_V_Url = loo_JResp.StringOf("user.url")
ls_Nostrudacc = loo_JResp.StringOf("user.user_fields.nostrudacc")
ls_In_80e = loo_JResp.StringOf("user.user_fields.in_80e")
li_Proident_e2 = loo_JResp.BoolOf("user.user_fields.proident_e2")
li_Voluptate_98 = loo_JResp.IntOf("user.user_fields.voluptate_98")
ls_Verified = loo_JResp.StringOf("user.verified")
destroy loo_Http
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -u login:password -X PUT
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"user": {
"name": "<string>",
"email": "<string>",
"custom_role_id": "<integer>",
"external_id": "<string>",
"identities": [
{
"type": "<string>",
"value": "<string>"
},
{
"type": "<string>",
"value": "<string>"
}
],
"organization": {
"name": "<string>"
},
"organization_id": "<integer>",
"role": "<string>"
}
}'
https://example.zendesk.com/api/v2/users/:user_id
Postman Collection Item JSON
{
"name": "Update User",
"request": {
"method": "PUT",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"user\": {\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"custom_role_id\": \"<integer>\",\n \"external_id\": \"<string>\",\n \"identities\": [\n {\n \"type\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"type\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"organization\": {\n \"name\": \"<string>\"\n },\n \"organization_id\": \"<integer>\",\n \"role\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id"
],
"variable": [
{
"key": "user_id",
"value": "<integer>"
}
]
}
},
"response": [
{
"name": "Success response",
"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 \"user\": {\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"custom_role_id\": \"<integer>\",\n \"external_id\": \"<string>\",\n \"identities\": [\n {\n \"type\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"type\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"organization\": {\n \"name\": \"<string>\"\n },\n \"organization_id\": \"<integer>\",\n \"role\": \"<string>\"\n }\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v2/users/:user_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"users",
":user_id"
],
"variable": [
{
"key": "user_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"user\": {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"alias\": \"<string>\",\n \"chat_only\": \"<boolean>\",\n \"created_at\": \"<string>\",\n \"custom_role_id\": \"<integer>\",\n \"default_group_id\": \"<integer>\",\n \"details\": \"<string>\",\n \"email\": \"<string>\",\n \"external_id\": \"<string>\",\n \"iana_time_zone\": \"<string>\",\n \"id\": \"<integer>\",\n \"last_login_at\": \"<string>\",\n \"locale\": \"<string>\",\n \"locale_id\": \"<integer>\",\n \"moderator\": \"<boolean>\",\n \"notes\": \"<string>\",\n \"only_private_comments\": \"<boolean>\",\n \"organization_id\": \"<integer>\",\n \"phone\": \"<string>\",\n \"photo\": {\n \"dolorea1\": false,\n \"deserunt3\": 95124319.10825741\n },\n \"remote_photo_url\": \"<string>\",\n \"report_csv\": \"<boolean>\",\n \"restricted_agent\": \"<boolean>\",\n \"role\": \"<string>\",\n \"role_type\": \"<integer>\",\n \"shared\": \"<boolean>\",\n \"shared_agent\": \"<boolean>\",\n \"shared_phone_number\": \"<boolean>\",\n \"signature\": \"<string>\",\n \"suspended\": \"<boolean>\",\n \"tags\": \"<array>\",\n \"ticket_restriction\": \"<string>\",\n \"time_zone\": \"<string>\",\n \"two_factor_auth_enabled\": \"<boolean>\",\n \"updated_at\": \"<string>\",\n \"url\": \"<string>\",\n \"user_fields\": {\n \"nostrudacc\": -12929960.546221554,\n \"in_80e\": 25167751.960886702,\n \"proident_e2\": true,\n \"voluptate_98\": -58995022\n },\n \"verified\": \"<boolean>\"\n }\n}"
}
]
}