Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring only task id in an array
    text
    copied!<p>I am creating a program that will automate some functions with Asana for my workplace but am a bit stuck. I am able to submit multiple tasks to a workspace and retrieve the task ID's of each but was wondering how to take only the ID portion of the response and store it into an array or list in C#. </p> <p>The response from the GET on <code>/tasks?workspace=&lt;workspace-id&gt;&amp;assignee=me</code> is:</p> <pre><code>{"data":[{"id":2177890732156,"name":"&lt;name of my task&gt;"}]} </code></pre> <p>I want to store the id number(s) from all my tasks into an array so I can perform an addProject PUT to each of them. </p> <p>I am using a serializer to put data elements into the proper dictionary for POSTing but am wondering if there is a way to reverse it and parse only the int portion of the response, store it in an array and call it back up.</p> <p>The serializer code is as follows:</p> <pre><code>public static string GetJsonByObject(object _object) { /// Serialize to JSON DataContractJsonSerializer serializer = new DataContractJsonSerializer(_object.GetType()); MemoryStream ms = new MemoryStream(); serializer.WriteObject(ms, _object); return Encoding.Default.GetString(ms.ToArray()); } </code></pre> <p>and I have been storing my requests in a byte array as follows:</p> <pre><code>string content; content = GetJsonByObject(t); bArrContent = Encoding.UTF8.GetBytes(content); request.GetRequestStream().Write(bArrContent, 0, bArrContent.Length); request.GetRequestStream().Close(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload