Pramod KB Pramod KB - 3 months ago 19
C# Question

Attask - Create a new user via API

I am integrating a .Net application with Work-front, I am supposed to create a new user in work-front from API. I have tried the steps mentioned in the link and my code

https://{mycompany}.attasksandbox.com/attask/api/user?updates={emailAddr:testuserAPI@domain.com,firstName:testuser,lastName:API}&username=myname@domain.com&password=password&method=post


From my console application I get internal server error 500. From fiddler I get parse error.

https://{mycompany}.attasksandbox.com/attask/api/5.0/user?updates={"emailAddr":"testuserAPI@domain.com","firstName":"testuser","lastName":"sample","roleID":"testrole","password":"pwd123res"}&method=post&sessionID=sdfdsdf1


Above code gives unrecognized URI format: too many parts - exception

Though my requirement is to authorise using API key, I was trying possible ways of achieving it.But I am not able to create in any of the ways.However, I am able to create from UI, which confirms my ID has rights to create user. I did look into API explorer and could see named functions,but whats the approach?Is there any documentation for these complete steps? My search was in-vain. Please suggest as I am new bee to workfront. Thanks in advance!

Update 1:

I was able to create a user via the API authorising by both API key and sessionID. The parameter I missed to pass is username (not necessarily an existing username). My code is -

https://{mycompany}.attasksandbox.com/attask/api/user?updates={"firstName":"Test","lastName":"API","username":"TestAPI@domain.com","emailAddr":"test2@test.com"}&method=post&apiKey=t---------------------u


My first step is resolved. There are 2 more steps which I need to perform. Calling named action - assignUserToken. I tried the code as below and it didn't work
https://{mycompany}.attasksandbox.com/attask/api/5.0/user/ID=4556ffs3324?action=assignUserToken&apiKey=t---------------u&method=put


ID is value returned while creating a user. Error returned is -
{"error":{"class":"java.lang.IllegalArgumentException","message":"null objCode"}}

Can you share the syntax of calling this named action?

Answer

Hi Your call has a few things wrong with It 1st you are calling

api/5.0 

this needs to be

api/v5.0

2nd you are calling

api/v5.0/user/ID=4556ffs3324 

it should be

api/v5.0/user/4556ffs3324

Other then that I dont see anything else wrong with the call.