Contentful logo

Contentful Community

How to retrieve user's name via Ruby Management API client?

#1

Hi,

I’m attempting to retrieve the first name and last name of a user, who has created an entry. More specifically, I’m attempting to search for user details matching a user ID.

require "contentful/management"

client = Contentful::Management::Client.new('XYZ123')
space  = client.spaces.find('XYZ123')
creator_id = space.entries.find('XYZ123').sys[:createdBy].id

In other words, how to find out who variable creator_id really is? Does the Management API even has this feature yet?

When I list the available methods in the client object…

client.users.methods

There are methods like new, find, all and me, but none of them seem to do anything. My first guess would be to try something like…

client.users.find(creator_id)

…but unfortunately, that doesn’t work.

0 Likes

#2

Hey @teemu.tammela1,

Our API does not support lookup for users other than the one authenticated with the current personal access token (which we have aliased to me).

The find operation on the users proxy is available, but the only valid value to pass is 'me', otherwise the API will return a 404, other methods are not supported.

Hope this helps,

Cheers

0 Likes

#3

Hi @david.litvak,

Thanks for the answer. Are there any plans to implement the functionality or something resembling it any time in the near future?

0 Likes