How to determine if a user has a profile image without downloading it?

imholzj
imholzj Posts: 7 🔍
edited May 2023 in Social Groups

While I could use: GET /d2l/api/lp/(version)/profile/user/(userId)/image

https://docs.valence.desire2learn.com/res/user.html#get--d2l-api-lp-(version)-profile-user-(userId)-image

It would be nice not to download the image if I don't have to. I see there is a data structure: User.User which contains the imageURL

https://docs.valence.desire2learn.com/res/user.html#User.User

But what call can I make to get the User.User data structure returned?

jji

Tagged:

Answers

  • Viktor.H.147
    Viktor.H.147 Posts: 50
    edited May 2023

    As a guess, you could try calling the "get my profile image" API route with a HEAD method instead of GET — HEAD is supposed to (generally speaking in web requests) behave just like a GET, except not actually return the data you'd get in the GET. I'm not sure if this will actually work with the Brightspace APIs, but it strikes me that, if it does work, it would be the most straightforward way to check to see if you have a profile image. (If you want to check for other users besides the calling user, then you can try a HEAD on the "get profile image for user-by-user-ID" route.)

  • imholzj
    imholzj Posts: 7 🔍

    Thanks for the response, might work, but the integration tool we're using (Talend) doesn't seem to support verbs other than GET and POST.

    jji

  • There is currently no call to determine if a user-by-user-ID has a profile image without fetching the profile image; you're correct that the User.User structure does include profile data for the user, but it's only used in other API contexts when the user might be associated (such as enrollments) and it mixes together user profile information and user information.