Obtaining discussions assigned to current user via API

Troy's Avatar

Troy

17 Sep, 2013 09:14 PM

Hi all,

I'm looking at /discussions/pending in the API, but user_current=1 returns all discussions visible to that user. Is there a way to get all discussions assigned to the current (API token owner) user?

Thanks,

Troy

  1. 1 Posted by Nicole on 18 Sep, 2013 02:31 PM

    Nicole's Avatar

    Troy -

    You'll see in the User section of the API docs how to get a specific single user - https://help.tenderapp.com/kb/api/users - and within those results, how to get all discussions for that user under the discussions_href variable. Let us know if you have any questions.

    Thanks,
    Nicole

  2. Nicole closed this discussion on 18 Sep, 2013 02:31 PM.

  3. Troy re-opened this discussion on 18 Sep, 2013 03:22 PM

  4. 2 Posted by Troy on 18 Sep, 2013 03:22 PM

    Troy's Avatar

    Hi Nicole,

    Thanks for the prompt reply. Is that discussions assigned to the user in
    question, or discussions visible to them? The users API doc page you linked
    to says "by this user," so I'm not sure whether that's opened by them,
    visible to them, or assigned to them (what I'm after).

    If it helps, the users API doc page links to the discussions doc, and the
    discussions doc has a similar problem but with a different word:
    "Discussions For User." :-)

    If it's easier than explaining to me, feel free to change either or both
    pages to explain which of the 3 the 2 calls returns and I'll re-RTFM.

    Thanks,

    Troy

  5. 3 Posted by Nicole on 18 Sep, 2013 03:52 PM

    Nicole's Avatar

    Troy -

    The way I'm reading the docs, it's all the discussion by the user, ie, the same tickets you'd see when you're on their profile page.

    If you're looking for all discussions assigned to a support user, then that is just a queue - https://help.tenderapp.com/kb/api/queues - where the name would be whatever the user's name is.

    Thanks,
    Nicole

  6. 4 Posted by Troy on 18 Sep, 2013 04:06 PM

    Troy's Avatar

    Hi Nicole,

    I don't think it's what you described. I'm looking at the profile page for the token owner, with "Open" checked (https://my.tenderapp.com/profile?pending=1), and I'm seeing a far larger set of tickets than discussions/pending?user_current=1 returns.

    I see hundreds of tickets on the token owner's profile page, and 30 via the API.

    All 3 of the links at the top of that page (Unread, Open, All) return far more tickets than the API target.

    Just from looking around and the fact that the count matches, I'm fairly sure that discussions/pending returns the same as what's on https://my.tenderapp.com/dashboard (the "Pending" sidebar link). For clarity, I'm hitting discussions/pending?auth=abc123&per_page=100&user_current=1.

    The thing I don't understand is what user_current=1 is doing. I get the 30 pending tickets regardless.

    It feels like we're all guessing at what the docs mean. Can you check the source and update the docs so they're clear?

    Thanks,

    Troy

  7. 5 Posted by Julien on 18 Sep, 2013 06:53 PM

    Julien's Avatar

    Hey Troy,

    So:

    • https://api.tenderapp.com/yoursite/users/12345/discussions returns all the discussions created by this user.

    • discussions/pending?user_current=1 wouldn't work as those can't be mixed. It's the same call as discussions/pending.

    • discussions?user_current=1 and discussions?user_id=X return discussions created by the user. I clarified the docs. To make it even clearer, users/X/discussions == discussions?user_id=X

    • What you see on your profile page is all the discussions you are watching, which in effect is all the discussions you have access to. There isn't a simple way to obtain that information through the API right now.

    • Assigning a discussion to a user is really just assigning it to this user's queue. So if you want all the discussions assigned to user X, you need to do:

      • /queues to get all the queues. You can then filter that list to find the queue Y that has user_id == X.
      • /queues/Y/discussions to get all the discussions assigned to this user.

    Getting the assigned discussions is definitely much harder than it needs to be. I need, at the very least, to provide the queue ID/href when you query the user. That alone would go a long way. It's really not that difficult so I hope I'll get to it in the next few days, but that should get you started.

    If you have any question, let me know.

  8. 6 Posted by Troy on 18 Sep, 2013 10:50 PM

    Troy's Avatar

    Thanks, both of you. That's exactly what I needed to know. No problem at all, and if no changes come of it, at least I can figure out what's happening now :)

    In utopia, the one call I'd want is a symbolic /queues/mine which does the lookup for me. I don't want it to save the second API call as much as because I don't have the user's ID and don't see a way of getting it (knowing just their API token, not email address). Best case, there's a way to turn token into user ID, worst case, the token alone isn't enough to navigate to the owner's queue.

    In that utopia, everything else I'd need is handled by the existing API, and I'd end up hitting /queues/mine/discussions/pending.

    Cheers,

    Troy

  9. 7 Posted by Troy on 18 Sep, 2013 10:50 PM

    Troy's Avatar

    PS, thanks for thinking through this so thoroughly with me. I know some of these questions get into the weeds.

    Troy

  10. 8 Posted by Julien on 18 Sep, 2013 11:50 PM

    Julien's Avatar

    Hey Troy,

    You can get the current user at /profile. I'll add it to the KB.

  11. 9 Posted by Julien on 25 Sep, 2013 07:05 PM

    Julien's Avatar

    Hey Troy,

    I just deployed a small change to the API: you can now use mine instead of a queue ID. I updated the docs as well.

    Let me know how it goes.

    Cheers!

  12. 10 Posted by Julien on 25 Sep, 2013 07:10 PM

    Julien's Avatar

    On the subject of tricks, I regularly use Echo to play with APIs and keep track of example requests. I wish it had curl export, but it's still practical as is. And it's only 4 bucks, so what's not to love :)

  13. 11 Posted by Troy on 25 Sep, 2013 09:37 PM

    Troy's Avatar

  14. Julien closed this discussion on 25 Sep, 2013 09:51 PM.

  15. Troy re-opened this discussion on 14 Oct, 2013 04:53 PM

  16. 12 Posted by Troy on 14 Oct, 2013 04:53 PM

    Troy's Avatar

    Hey Julien, one more tiny related question. Is there a way to obtain the set of pending discussions in the API token owner's queue? If not, no problem, I just wanted to check. Right now I'm using /queues/mine and it works great, but still picks up resolved discussions. If the equivalent to /discussions/pending existed and was specific to /queues/mine, I'd use it instead.

    And thanks, too!

    Troy

  17. 13 Posted by Julien on 14 Oct, 2013 05:02 PM

    Julien's Avatar

    Try /discusssions/pending?queue_id=mine. That should work.

  18. Julien closed this discussion on 18 Oct, 2013 10:59 PM.

Discussions are closed to public comments.
If you need help with Tender please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac