PowerBuilder / Support API / Get sources by target
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
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_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_In1f
integer li_Cillumb5
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_Url
string ls_Nisi_e
string ls_Verified
integer li_Ut69
integer li_Magna_4
integer li_Loremcc
integer li_Dolore7
string ls_Pariaturf
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"
loo_Http.SetRequestHeader("Accept","application/json")
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://example.zendesk.com/api/v2/:target_type/:target_id/relationship_fields/:field_id/:source_type",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_SbResponseBody
return
end if
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_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "users": [
// {
// "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": {
// "in1f": false,
// "cillumb5": true
// },
// "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": {
// "nisi_e": "commodo exercitation consequat"
// },
// "verified": "<boolean>"
// },
// {
// "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": {
// "ut69": true,
// "magna_4": -92520384
// },
// "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": {
// "Loremcc": 52379422,
// "dolore7": true,
// "pariaturf": "magna consectet"
// },
// "verified": "<boolean>"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
i = 0
li_Count_i = loo_JResp.SizeOfArray("users")
do while i < li_Count_i
loo_JResp.I = i
ls_Name = loo_JResp.StringOf("users[i].name")
ls_Active = loo_JResp.StringOf("users[i].active")
ls_Alias = loo_JResp.StringOf("users[i].alias")
ls_Chat_only = loo_JResp.StringOf("users[i].chat_only")
ls_Created_at = loo_JResp.StringOf("users[i].created_at")
ls_Custom_role_id = loo_JResp.StringOf("users[i].custom_role_id")
ls_Default_group_id = loo_JResp.StringOf("users[i].default_group_id")
ls_Details = loo_JResp.StringOf("users[i].details")
ls_Email = loo_JResp.StringOf("users[i].email")
ls_External_id = loo_JResp.StringOf("users[i].external_id")
ls_Iana_time_zone = loo_JResp.StringOf("users[i].iana_time_zone")
ls_Id = loo_JResp.StringOf("users[i].id")
ls_Last_login_at = loo_JResp.StringOf("users[i].last_login_at")
ls_Locale = loo_JResp.StringOf("users[i].locale")
ls_Locale_id = loo_JResp.StringOf("users[i].locale_id")
ls_Moderator = loo_JResp.StringOf("users[i].moderator")
ls_Notes = loo_JResp.StringOf("users[i].notes")
ls_Only_private_comments = loo_JResp.StringOf("users[i].only_private_comments")
ls_Organization_id = loo_JResp.StringOf("users[i].organization_id")
ls_Phone = loo_JResp.StringOf("users[i].phone")
li_In1f = loo_JResp.BoolOf("users[i].photo.in1f")
li_Cillumb5 = loo_JResp.BoolOf("users[i].photo.cillumb5")
ls_Remote_photo_url = loo_JResp.StringOf("users[i].remote_photo_url")
ls_Report_csv = loo_JResp.StringOf("users[i].report_csv")
ls_Restricted_agent = loo_JResp.StringOf("users[i].restricted_agent")
ls_Role = loo_JResp.StringOf("users[i].role")
ls_Role_type = loo_JResp.StringOf("users[i].role_type")
ls_V_shared = loo_JResp.StringOf("users[i].shared")
ls_Shared_agent = loo_JResp.StringOf("users[i].shared_agent")
ls_Shared_phone_number = loo_JResp.StringOf("users[i].shared_phone_number")
ls_Signature = loo_JResp.StringOf("users[i].signature")
ls_Suspended = loo_JResp.StringOf("users[i].suspended")
ls_Tags = loo_JResp.StringOf("users[i].tags")
ls_Ticket_restriction = loo_JResp.StringOf("users[i].ticket_restriction")
ls_Time_zone = loo_JResp.StringOf("users[i].time_zone")
ls_Two_factor_auth_enabled = loo_JResp.StringOf("users[i].two_factor_auth_enabled")
ls_Updated_at = loo_JResp.StringOf("users[i].updated_at")
ls_Url = loo_JResp.StringOf("users[i].url")
ls_Nisi_e = loo_JResp.StringOf("users[i].user_fields.nisi_e")
ls_Verified = loo_JResp.StringOf("users[i].verified")
li_Ut69 = loo_JResp.BoolOf("users[i].photo.ut69")
li_Magna_4 = loo_JResp.IntOf("users[i].photo.magna_4")
li_Loremcc = loo_JResp.IntOf("users[i].user_fields.Loremcc")
li_Dolore7 = loo_JResp.BoolOf("users[i].user_fields.dolore7")
ls_Pariaturf = loo_JResp.StringOf("users[i].user_fields.pariaturf")
i = i + 1
loop
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -u login:password -X GET
-H "Accept: application/json"
https://example.zendesk.com/api/v2/:target_type/:target_id/relationship_fields/:field_id/:source_type
Postman Collection Item JSON
{
"name": "Get sources by target",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/:target_type/:target_id/relationship_fields/:field_id/:source_type",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
":target_type",
":target_id",
"relationship_fields",
":field_id",
":source_type"
],
"variable": [
{
"key": "target_type",
"value": "<string>"
},
{
"key": "target_id",
"value": "<integer>"
},
{
"key": "field_id",
"value": "<integer>"
},
{
"key": "source_type",
"value": "<string>"
}
]
},
"description": "Returns a list of source objects whose values are populated with the id of a related target object. For example,\nif you have a lookup field called \"Success Manager\" on a ticket, this endpoint can answer the question,\n\"What tickets (sources) is this user (found by `target_type` and `target_id`)\nassigned as the 'Success Manager' (field referenced by `field_id`)?\"\n\n#### Allowed For\n\n* Agents\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/:target_type/:target_id/relationship_fields/:field_id/:source_type",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
":target_type",
":target_id",
"relationship_fields",
":field_id",
":source_type"
],
"variable": [
{
"key": "target_type"
},
{
"key": "target_id"
},
{
"key": "field_id"
},
{
"key": "source_type"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"users\": [\n {\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 \"in1f\": false,\n \"cillumb5\": true\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 \"nisi_e\": \"commodo exercitation consequat\"\n },\n \"verified\": \"<boolean>\"\n },\n {\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 \"ut69\": true,\n \"magna_4\": -92520384\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 \"Loremcc\": 52379422,\n \"dolore7\": true,\n \"pariaturf\": \"magna consectet\"\n },\n \"verified\": \"<boolean>\"\n }\n ]\n}"
}
]
}