Skip to main content

Hi Rui,



Thank you very much for your answer. This is exactly what I was looking for.



Now I think the way to achieve my goal is to create a webhook with ‘COLLABORATION.ACCEPTED’ trigger, that way I can assign the approval task to the user. So I need the user id to assign the task.


But is ‘collab.id’ the user id? The API documentation doesn’t say so but I note that you wrote ‘Collaborator:’.



Cheers

Hi @Ooshot ,



To your question, the collaboration id is not the user id.



Within the collaboration object, which essentially links a file or folder to a user, there is a section called accessible_by. This represents the user “collaborated”.



So in the previous example if we add this line before deleting the collaboration:



print(

f"Collaboration User: {collab.accessible_by.id} {collab.accessible_by.type} {collab.accessible_by.name} {collab.accessible_by.login}"

)



You get the user object that was collaborated:


Collaboration User: 18685785980 user barbasr@gmail.com barbasr@gmail.com



You can also list the existing collaborations by file or folder. In the previous example:



# get the folder collaborators

collaborators = folder.get_collaborations()

print(f"Folder {folder.name} ({folder.id}) collaborators:")

for collaborator in collaborators:

print(

f"\tCollaborator: {collaborator.id} {collaborator.status} role: {collaborator.role} invite: {collaborator.invite_email})"

)



With the COLLABORATION.ACCEPTED webhook, you get the collaboration.id, from there you get the user, for which you can create a task.



Note that my example was collaborating a folder, and tasks are only applicable to files.



Here is some documentation examples specific for the Python SDK:





Cheers


Reply