Issues to get a list of task back

Hi,

I am currently facing an issue that when i passed an array of taskids to get a list of tasks back the code was stuck somewhere and no response. if i pass taskid one by one in a for-each, it has no problem to get the task back.

The method i called was: octopusRepository.Tasks.Get()

Regards,
Ben

Hi Ben,

Thanks for reaching out. That Get() method needs an string[] (array of strings) and not a List<String>. If you have a list of string you could do this:

var tasks = new List<string>();
tasks.Add("ServerTasks-7445");
tasks.Add("ServerTasks-7444");
OctopusRepository.Tasks.Get(tasks.ToArray());

Let me know if that works.

Edit: Totally disregard the above reply. I misread your ticket and I thought you were pasing a List<String> to that method

That Get() method will swipe through the entire list of tasks to get the ones that match those IDs, which would explain why your program gets stuck.

From a performance perspective, I recommend you to stick with the foreach loop + passing a single ID at a time, which will fetch only that particular ID without reading the entire list.

Best regards,

Dalmiro

Thanks for your reply.

the for-each way works fine now.

just curious, what reason it could be causing this stuck/no response to get them all back together.

You could setup Fiddler to see how many API requests are being made and how much they are taking. That would be the best way to troubleshoot the stuck/slowness.

That said, I wouldn’t wast too much time on it as I can confirm that the foreach loop will be much better performance-wise :slight_smile:

Cool. thanks for your advice~~