Not signed in (Sign In)
The Intervals Forum is read-only
Please head to help.myintervals.com for help articles and guides. If you have any questions, please contact our support team.

API

GET time - one vs many

Bottom of Page

1 to 4 of 4

  1.  
    • tsmith339
    • Feb 21st 2014 edited @ 02/21/2014 6:50 am
     

    Hi all,
    I have found that when I get a single time ("/time/22123734/") vs getting all the time for a person ("/time/?personid=128649") the returned object is different. I am trying to find out why, and secondly, how to handle this in C#.

    Here are examples
    Returning a single time

    {
    "personid":128649,
    "status":"OK",
    "code":200,
    "time":{
    "id":"22123734",
    "projectid":"71347",
    "moduleid":"81795",
    "taskid":null,
    "worktypeid":"129310",
    "personid":"99233",
    "date":"2014-03-18",
    "datemodified":"2014-01-28 13:23:14",
    "time":"8",
    "description":"Out of Office - Travel --sdr",
    "billable":"f",
    "worktype":"General Work"
    }
    }


    And here is the return when requesting multiple times
    {
    "personid":128649,
    "status":"OK",
    "code":200,
    "listcount":1338,
    "time":[
    {
    "id":"xxxxx",
    "projectid":"xxxxx",
    "moduleid":"xxxxx",
    "taskid":"xxxxx",
    "worktypeid":"xxxxx",
    "personid":"xxxxx",
    "date":"06\/20\/2013",
    "time":"0.25",
    "description":"Updated xxxxx Parallel to 12.2.0.16",
    "billable":"f",
    "datemodified":"2013-06-20 13:32:28",
    "dateiso":"2013-06-20",
    "module":"Setup",
    "project":"xxxxxx Personnel",
    "worktype":"*Support - Offsite",
    "tasklocalid":"34673",
    "task":"Upgrade xxxxx Parallel",
    "firstname":"Tim",
    "lastname":"xxxxx",
    "active":"t",
    "person":"Tim xxxxx",
    "clientid":"xxxxx",
    "client":"xxxxxx Personnel",
    "clientactive":"f",
    "statusid":"1"
    },
    {......}]
    }


    The amount of fields that come back when multiple times are returned is much higher.
    Can anybody explain why this is?

    Also, I am working on a C# project serializing/deserializing using DataContractJsonSerializer. I have constructed a time model class based on the second example using DataContract and DataMember attributes.
    My problem is when I request a single time like the first example, it doesn't serialize because of the data contract.

    Is there a better way to go about this? Does another library like Newtonsoft JSON handle this better?

    Thank you!

    Tim
  1.  
    I tested out Newtonsoft JSON.net and it does the trick. If somebody still has the answer as to why the returned objects are different, though, that would be great.
  2.  

    tsmith,

    The list query returns more fields if you need to build a custom view of the time. This way project names for example are included and you don't need to do an extra query to look up its name from the projectid.

    I believe the error is because the API is rejecting some fields from a POST request. This is by design, because those extra fields are read-only. When submitting a POST request just make sure only the read-write fields are submitted. You can get these by viewing the Member section of the time resource.

  3.  
    Thanks jprado!

Comments are closed.
For more Intervals help documentation, please visit help.myintervals.com