2

I am wondering if whether in the API for AtTask there is a method for posting multiple updates in a single URL request.

As an example, I need to update the extRefIDs on 1,000 records. Do I make 1,000 calls to the API (expensive in terms of overhead), or can I send a single request with a JSON or XML payload that contains something like this:

{data {id:1234,extRefID:xx} {id:1235,extrefID:xy} }

etc? Would certainly be less overhead on both systems if there was a method for this. Thanks in advance!

joefox97
  • 59
  • 7
  • Perhaps something like request batching, a la https://aspnetwebstack.codeplex.com/wikipage?title=Web%20API%20Request%20Batching ? – joefox97 Feb 17 '14 at 15:59
  • I don't think current API can do that. I ended up making thousands of separate calls. It went surprisingly quick though (production faster than testing too). – Geo Feb 17 '14 at 17:10
  • 1
    Thanks, Geo. I've found the same. I suppose from a RESTful perspective that's the "right" way to go, but the DBA in me is twitching. :) – joefox97 Feb 17 '14 at 20:33

1 Answers1

1

You can do bulk updates on objects of the same type by passing in a single JSON array into the "updates" parameter:

PUT .../api/v4.0/task?updates=[{"ID":"abc123","extRefID":"val1"},{"ID":"def456","extRefID":"val2"}]

Hope this help.

Joel
  • 16,474
  • 17
  • 72
  • 93
  • Thanks much! This should save a TON of calls. – joefox97 Feb 18 '14 at 18:49
  • I'm getting a 504 when I pass a large number of requests to the updates parameter. The HTML request looks well formed -- but as soon as it hits 512 bytes (according to Fiddler), I get a 504 gateway timeout. I'll keep fiddling with it, but any thoughts on this behavior? – joefox97 Feb 18 '14 at 20:22
  • I've seen that before when using a GET request, or when putting all the update data in the URL instead of in the body of a POST/PUT request. Not sure what language you are using but most languages have a way of setting parameters for POST data that is separate from just specifying it in the URL. – Sean Feb 19 '14 at 19:17
  • Well, I got this working for small batches; that will help some. Would be nice to have a better idea why it's failing for large batches. – joefox97 Feb 24 '14 at 21:17
  • 1
    @joefox97, did you try Sean's suggestion? It should work as long as your large data is being passed in the body of the PUT/POST rather than the querystring. – Joel Feb 27 '14 at 20:51
  • Is that the only thing that belongs in the body, or must I also include the sessionID and other components? I'm guessing the body should look like this: `updates=[{"ID":"abc123","extRefID":"val1"},{"ID":"def456","extRefID":"val2"}]` ? – joefox97 Feb 27 '14 at 21:59
  • you should be able to leave the session ID in the querystring or put it in the body. – Joel Mar 06 '14 at 18:21