Recent searches
No recent searches
Contact access from ticket side bar
Posted Jun 09, 2023
Hi,
I am creating a app, location - "new_ticket_sidebar" and "ticket_sidebar". There i am able to fetch the current ticket details and the customer id using the below code :-
client.get('ticket').then(function(data) {
let contactId =data.ticket.requester.id;
console.log("contactId of the ticket is : ",contactId);
});
});
I need data of other customer details like name, phone number etc. of this customer id . Can anybody help me how I can get that info ?
1
7
7 comments
Cheryl Lane
Hi,
You can get details for a user using the users API https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user . To access that from the ticket sidebar location, you'd use the client.request method, like this:
const user_details = await client.request(`/api/v2/users/${contactId}.json`)
Then you can get the details you're looking for from that object.
Hope that helps,
Cheryl
1
Himanshu Sehgal
Hi Cheryl,
Thanks for your reply. It works fine ! But I don't understand how. Can you please explain a bit that why no Authorization header was needed for this api request ?How it worked without any api token or any sort of authentication ?
0
Greg Katechis
Hi Himanshu! When making an API request to the same account that the ZAF app is installed in, and when using our `request()` method, we use the browser's session cookie for your instance as we document here.
1
Cheryl Lane
As Greg says, requests made by client.request will use the existing Zendesk authentication, so you can call all Zendesk apis this way without having to specify a domain/subdomain or manage any authentication credentials. As you've seen, very handy!
0
Himanshu Sehgal
Hi Greg and Cheryl,
Thanks for the clarification. This indeed is quite handy. However, now I am facing a little bit different issue related to the data in the response of the /users api. As shown below, you can see I have saved 3 contact numbers for the user :-
BUT when i am calling the /users api, I am getting only 1 phone number in the json response :-
I need to know why is this happening , and Is there any way to get all the phone numbers of the contact ?
Thanks !
0
AntonMi
Himanshu Sehgal You may use Identities
https://developer.zendesk.com/api-reference/ticketing/users/user_identities/
0
Himanshu Sehgal
Hi Anton,
Thanks for the solution! Cheers!!
0