Search code examples
rubyarraysjsonhttp-postattask

AtTask URI endpoints


I have been in the process of building a small application to pull and push data using the API and have a few questions regarding where I can post an array of hashes containing new data to the reservedTimes (RESVT) endpoint. As it has been previously asked on SO, one can use the '?updates=' modifier to post an array of hashes containing existing RESVT and New RESVT information. I am only concerned with making a series of POST requests with an array of hashes solely containing new RESVT data on a user to user basis. Specifically, I am looking for a way to post multiple dates for a single user. My understanding is that the RESVT field is stored as a collection under the USER object so RESVT data needs to be posted as a collection. My array is formatted like [{'userID'=>ID, 'startDate'=>startDate, 'endDate'}, {'userID'=>ID, 'startDate'=>startDate, 'endDate'}, {'userID'=>ID, 'startDate'=>startDate, 'endDate'}] If my URL looks something like: https://[domain].attasksandbox.com/attask/api/resvt?updates= (only the updates modifier is returning a 400 (bad request) with a message saying,

"Cannot mix 'updates' JSON parameter with non-JSON update parameter"

Has anybody else found a solution to this?

I appreciate your help in advance!


Solution

  • This would work but your url format would have to be like this

    /attask/api/resvt?updates=[{"endDate":"2014-12-25T22:59:00:163-0700","startDate":"2014-12-24T23:00:00:163-0700","userID":"4ee8cfec000d2cd780c3ccf059cdc23b"},{"endDate": "2014-12-26T22:59:00:163-0700","startDate":"2014-12-26T23:00:00:163-0700","userID":"4ee8cfec000d2cd780c3ccf059cdc23b"}]&method=POST&sessionID={sessionID}
    

    The problem you will run into is this will erase all existing time off already in the system.

    one solution is to pull all time-off from attask first then append the new time off to the collection.

    or

    Send all time-off dates with each call.

    If you are interested we are working on updating the example code and updating time-off is part of that update. If you interested I can provide samples in any of the sample code languages except flex.

    If you are interested in that please enter a help desk ticket into attask and let the support rep know to contact Michael Johnson.