1

I have the API functioning fine within my project for non custom fields, but the documentation doesn't really seem to work in relation to explaining what the actual put request format should be for updating a custom field using c sharp.

I have the following:

Custom Field of type PROJECT called "TestNumber".

I can easily search it with the web request:

/attask/api/proj/search?sessionID=XXXXXXX&ID=XXXXX&fields=DE:TestNumber

so I know that the syntax for that specific custom field is right.

I can also do a basic update on non custom fields:

/attask/api/proj?method=put&sessionID=XXXXX&id=XXXXX&name=TEST RESOURCES` 

and it properly updates.

But no matter what I do, I cannot figure out how to change the value of that "TestNumber" custom field, to a value that I choose using the API. After some searching, I found that I should be using the "JSON Edits" portion from the API docs of AtTask, however, I can't seem to figure out the proper syntax.

My fullurl prior to the attempt is:

/attask/api/proj?method=put&sessionID=XXXXX&id=XXXXXX&updates={DE:TestNumber:1234}

(which seems to jive with the API DOCS rec here http://developers.attask.com/api-docs/#JSONEdits) but I get a 500 Internal Server error every time.

I have verified that I am being properly logged in.

Any suggestions or advice would be greatly appreciated.

UPDATE: I still cannot get this to work. I found another post (search for "AtTask API Updating Multiple Values in Custom Checkbox Field") where the person mentioned this for a custom checkbox form:

PUT /attask/api/v3.0/task/xxxxxxxxxxxxxxxxxx?updates={DE:Labels=["a","b","c"]}

but I am not sure how to even pass that sort of data directly using C Sharp because it does not allow double quotes and when I add an escape character, I still get the 500 internal server error. I got the "Post" method to go by using %22 in the place of the quotes, but no matter what I do on the put, it does not work.

Our AtTask consultant mentioned that I might need to include my categoryId for the custom form, so I also added that to my querystring, but to no avail.

I have downloaded the "AtTask Example" for C Sharp (which is located on the developers.attask.com)and am trying to use the Update method that they use as the example passing the following:

JToken project = client.Update(ObjCode.PROJECT, new { 
    ID = projectId, categoryID = "XXXXXXXXXXXXXXXX", 
    updates = "{DE:Total Feet of Line:1234}" });

As I mentioned before, the Search works fine and returns exactly what I expect:

JToken projects = client.Search(ObjCode.PROJECT, new { 
    ID = projectId, 
    fields = "DE:Total Feet of Line" });

That generates the following url:

/attask/api/proj/search?sessionID=XXXX&ID=XXXX&categoryID=XXXXX&fields=DE:Total Feet of Line

I finally tried updating using "Json Edits" with non custom fields, and it works with the put method so I MUST have something wrong with my syntax on those fields, but I was CERTAIN that it is supposed to be DE:FIELDNAME:"VALUE". Am I wrong here?

I feel like I am on the correct track in terms of trying to solve this, but am finding it hard to believe that there is no support or other people who have done this. It seems like it is a basic need to be able to update a custom field from the API...

I also tried exactly following the other individuals example with a custom checkbox, and even though the "Search" returns the json as expected, the "Update" fails.

Zorgarath
  • 979
  • 12
  • 23

1 Answers1

2

You are right about "DE:FIELDNAME":"VALUE".

Try the following url to update the custom field: Make sure you change MYCOMPANY, YOUR_ID, YOUR_CAT_ID, YOUR_FIELD, YOUR_VALUE, YOUR_LOGIN_USERNAME, YOUR_LOGIN_PASSWARD.

MYCOMPANY.attasksandbox.com/attask/api/proj?updates={"ID":"YOUR_ID","categoryID":"YOUR_CAT_ID","DE:YOUR_FIELD":"YOUR_VALUE"}&method=put&username=YOUR_LOGIN_USERNAME&password=YOUR_LOGIN_PASSWARD

That works for me. Let me know if that works for you

Jim Young
  • 169
  • 2
  • Thanks Jim. What ID should I specifically be addressing given that from what I can tell, a customfield doenst have an "ID" but rather is addressable via the "DE:FIELDNAME". Also, does that syntax work for you on a custom field object of PROJECT type as well? I notice your example has the "task" so I wanted to verify that it also works for you on "project" type as well. – pachrist1981 Apr 08 '14 at 15:59
  • sorry was not that clear, ID would be the project id. I changed the above example from task to a project – Jim Young Apr 08 '14 at 16:00
  • the main idea here is the last part of that url: &method=put&username=YOUR_LOGIN_USERNAME&password=YOUR_LOGIN_PASSWARD – Jim Young Apr 08 '14 at 16:06
  • Yes, after I posted (and after the 5 minutes that it would have allowed me to edit) I figured that much and got it working. I will mess with more complex objects (like multi-selects) but mostly it seems to be working with numbers which is the most important thing for now. Thank you so much for taking the time to answer and help. – pachrist1981 Apr 08 '14 at 16:06