InvalidEndpoint error when using the Show Agent by Email API endpoint
Gepostet 16. Dez. 2022
I'm trying to update agents via API starting from the User record (creation of a new user) and running into some challenges. It looks like there is an Agent ID which is different from the User ID, so I first tried using the GET /api/v2/agents endpoint to show all agents, which I assumed would help me find the ID. This API call fails with a message 'You do not have access to this page. Please contact the account owner of this help desk for further help.' I'm the owner of the help desk and the account I'm using is a full admin for Zendesk as well, so I'm not sure why this call doesn't work (I tried the same thing using my own account and got the same error).
Since I couldn't make that work, I tried using GET /api/v2/agents/email/{email}. This also fails, with an error 'InvalidEndpoint'. I'd searched in the support forum for this error and it looks like it has happened when the request type is wrong, however using PUT or POST returns the same error. Other API calls work so I know the format and authentication is good. Has anyone been able to make either of these endpoints work as documented?
0
4 Kommentare
Mark Leci
CJ this is awesome, thank you so much for taking the time to write this up! It totally makes sense there is a separate call for group memberships since it's not a 1:1 relationship.
My first thought on how I'm going to handle this if it helps you at all (I'm using Zapier middleware with python code) is to look up the user id when an agent is created, then use a lookup table to associate a user with a set of groups (maybe based on a custom field for job title or something). I'll then update that user with the set of groups for their role. If I figure out how to grab this list of groups and make it usable in python I'll post that solution here.
It looks like the roles API is also part of the agent API under chat - we'll be using that in 2023, I'm kind of curious to know if you can only update users who are licensed for chat (which would be a pain) but otherwise I don't think there is a way to update the role via API. But thinking about it further, maybe having a single role for agents is better, and handling the rest via groups.
thanks again!
0
CJ Johnson
Good questions!
I do things weird I think, but it works for me. You can set groups via the API. Adding them is easy, removing them is a pain. But there's things you can do to mitigate that too.
I probably do things in a real weird way, because I've got a real weird background and training, so uh, keep that in mind!
To mass create users in a group, you can use this endpoint: https://domain.zendesk.com/api/v2/group_memberships/create_many.json
I send something that looks like this:
This would add all these uses to the group with that group id. But as you mention, how to do you get those IDs?
Well, for myself, I wrote a python script I run that returns a list of all active agents, their id, email, last sign, and creation date. I run it, then import it into a sheet. That's that 'api/v2/users.json?role[]=admin&role[]=agent&active=true'` thing I shared earlier. You can even run this in your browser and use konklone to turn it into a csv.
Do that again for your groups too: /api/v2/groups
Ok, so now we have a csv with agent IDs, and a csv with group ids. This is where I do dumb stuff that would better be served by a script but I use a Google sheet because I'm too green in Python still to get this coded out to the end result via Python.
On the first tab, I make a column for pasting in my agent emails. I then set up a VLOOKUP to match the email address to the ID from that earlier lookup we did, and pull that. I also set up the group ids on another sheet, just for my own reference.
I set up one sheet to be my "code out" that I will paste into Postman, and pull in row of IDs from the VLOOKUP from the first sheet in. I then look up the group ID and paste it in for as many users as I have rows to update:
Then I paste it in postman, delete the last stray comma, and hit send. This lets me update a large batch of agents to a new group easily. Set up takes a bit, but once you have it done, pasting in a list of agent emails and getting the code out is super fast.
Doing this, you could even program a Google sheets function to make an API call and return the user id for an email directly -- this is still a stretch goal for my project personally, but I know it's possible, I've built a few custom functions that check things like the status of a ticket ID in a cell for other projects.
I suspect Roles could be handled in a similar way, although I personally don't use the API for that as I rarely need to change folks from the default role.
0
Mark Leci
thanks CJ - the reason I was looking at agents originally is that the Users API doesn't have the ability to set roles or groups. However, looking at the Agents API, this also doesn't support those things any more (roles is deprecated).
This I guess brings up another question - how are others managing their agents? Since this isn't possible via API, do we really need to do all our updates and user creation manually?
0
CJ Johnson
Hi Mark,
I think you want "/api/v2/users" not "api/v2/agents". I typically use "api/v2/users.json?role[]=admin&role[]=agent&active=true'" to get all active admins and agents returned. I'm not seeing any documentation for that email endpoint either. Are you just trying to get it to return info on a user with that email address?
For your task, you may also find the import agent option easier -- you can upload a CSV with emails, and columns for the details you need to update, and mass update them all. You can't update everything this way (groups for example are not an option), but it does make it very easy to add tags to users, update custom profile fields, etc.
Fake edit: OH! I think you've gotten a bit lost in the documentation. The endpoints you're trying to hit are for the Live Chat product only, and live at a completely separate URL with a very difficult authentication workflow that's totally different than the other endpoints. The documentation is very confusingly set up IMO. The page you want for regular Zendesk Support API actions, is under the Ticket API for users.
0
Anmelden, um einen Kommentar zu hinterlassen.