Post
FollowAssigning a Resource to a task with api.
Hey, i have been having a bit of trouble assigning a user to a task using the API.
I was able to get all the users, and create objects for them all containing all the information. I was also able to do the same with the tasks i needed. so now i have all the information about the two things i just need to add the user as a resource to the task.
I have tried a bunch of stuff from the forums and know there must be a simple way seeing as i have every bit of info. was hoping to use the objects long id to do it. Its all in c#.
here is the 2 im testing on
User.Id: dcaba144-bd35-4146-9b0b-5e247206260d
Task.Id: 432a06eb-9a12-4362-b89e-e256ce1e0388
I was looking at the working with reference bit in the API sheet and trying to go with that, but that seems to be for linking 2 new entities and not not 2 existing one. Tried faffing about but i'm having no luck, any help would be really really appreciated!!
Stew
Please sign in to leave a comment.
7 comments
Date
Votes
Hi Stewart.
Thanks for sharing!
Your final code seems OK.
Was TypeName="ResourceLink" working for you? I think "RegularResourceLink" is better.
Ophir
It seemed to work and was reflected in Clarizen. Ill leave it for now and hope for the best!!
How to add multiple users to a task?
I have to write same code for individual users or in one shot i can do it??
Please suggest
Hi Bharti,
To add resources to a task with the API you can use the CreateMessage with a type name of RegularResourceLink (specify the Resource & WorkItem _fields, each as _EntityId).
In general you can send multiple message to the API in a single call (the Execute method accepts an array of messages).
Also note you can pack several message in a TransactionMessage.
Hope this helps
Ophir
Just to clarify, each CreateMessage should be used to create a single resource link.
Use several _CreateMessage _s if you want to add more than one.