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

Problem while etracting the data from intervals

Bottom of Page

1 to 2 of 2

  1.  
    • poonamc
    • Oct 10th 2012 edited @ 10/11/2012 8:22 am
     

    We are using intervals online for timesheet management of our company.I am accessing the api of intervals to get the data from intervals directly through java.It returns me the data but it does not match with data data which we get from the intervals summary.
    In intervals if i goto summary and generate the report for some specific date the xml data which i am getting does match with the summary.I have attached the sample code which i am using for your reference. Please reply asap,it is very urgent for us.

    Code sample:

    package com;
    import org.apache.commons.codec.binary.Base64;
    import java.net.*;
    import java.io.*;
    import javax.net.ssl.HttpsURLConnection;

    import java.text.SimpleDateFormat;
    import java.util.*;


    public class urlConnection{
    public static void main(String args[]) throws Exception {

    String token= API_TOKEN + ":";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date datebegin = sdf.parse("2012-10-11");
    Date dateend = sdf.parse("2012-10-11");
    String encoded = new String(Base64.encodeBase64(token.getBytes()));
    URL url = new URL("https://api.myintervals.com/time/datebegin=datebegin&dateend=dateend&limit=1000");
    //System.setProperty("java.net.useSystemProxies", "true");
    HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();
    httpsCon.setDoOutput(true);
    httpsCon.setRequestMethod("GET");
    httpsCon.addRequestProperty("Host", "api.myintervals.com");
    httpsCon.addRequestProperty("Accept", "application/xml");
    httpsCon.addRequestProperty("Authorization","Basic "+encoded);


    InputStream inStrm = httpsCon.getInputStream();

    int ch;
    String strFilePath = "C://Summary.xml";
    FileOutputStream fos = new FileOutputStream(strFilePath);
    while (((ch = inStrm.read()) != -1)){
    System.out.print((char) ch);
    fos.write((char)ch);
    // inStrm.close();
    }
    // System.out.println(encoded);
    //System.out.println("Response Message is " + httpsCon.getResponseCode());





    }
    }


    its expected to return following data
    Client # Project Person Module Work type Task Description Date Time Billable
    Nikhil Talwar F00428
    P&G 170 P&G Account Activities Nikhil Talwar F00428 Misc Holiday 10/11/2012 8 No
    Total for Nikhil Talwar F00428 8
    Dev Markandey F00577
    Chartis 255 Chartis - LAD Research Dev Markandey F00577 Research, Study & Review Analyst (Offsite) #5333: Review 10/11/2012 7 Yes
    Total for Dev Markandey F00577 7
    Nikhil Yogesh Sheth F00669
    Chartis 192 Chartis - Consumer - Auto Ratemaking Model Validation Nikhil Yogesh Sheth F00669 Modeling Analyst (Offsite) #1468: Model validation "Model Sanity Check and
    Creating Model Validation Template" 10/11/2012 8 Yes
    Total for Nikhil Yogesh Sheth F00669 8
    TOTAL 23

    which contains 3 records,

    but it returns 10 records

    <?xml version="1.0" encoding="UTF-8" ?>
    - <intervals personid="131050" status="OK" code="200" listcount="24330">
    - <time>
    - <item>
    <id>12994559</id>
    <projectid>317186</projectid>
    <moduleid>209967</moduleid>
    <taskid />
    <worktypeid>323620</worktypeid>
    <personid>131056</personid>
    <date>10/26/2012</date>
    <time>8.5</time>
    <description />
    <billable>f</billable>
    <datemodified>2012-10-01 04:31:19</datemodified>
    <dateiso>2012-10-26</dateiso>
    <module>Misc</module>
    <project>P&amp;G Account Activities</project>
    <worktype>Internal meetings</worktype>
    <tasklocalid />
    <task />
    <firstname>Saurabh Mehta</firstname>
    <lastname>F00236</lastname>
    <active>t</active>
    <person>Saurabh Mehta F00236</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>12994141</id>
    <projectid>316790</projectid>
    <moduleid>204542</moduleid>
    <taskid>2646282</taskid>
    <worktypeid>323645</worktypeid>
    <personid>131081</personid>
    <date>10/26/2012</date>
    <time>2</time>
    <description>To Chandralekha on design changes and documentation</description>
    <billable>t</billable>
    <datemodified>2012-10-01 03:34:11</datemodified>
    <dateiso>2012-10-26</dateiso>
    <module>Design</module>
    <project>P &amp; G - G4 Business Sufficiency</project>
    <worktype>Knowledge Transition</worktype>
    <tasklocalid>94</tasklocalid>
    <task>Country</task>
    <firstname>Saurabh Jain</firstname>
    <lastname>F00360</lastname>
    <active>t</active>
    <person>Saurabh Jain F00360</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13112185</id>
    <projectid>317186</projectid>
    <moduleid>209967</moduleid>
    <taskid />
    <worktypeid>326730</worktypeid>
    <personid>131100</personid>
    <date>10/12/2012</date>
    <time>8</time>
    <description />
    <billable>f</billable>
    <datemodified>2012-10-06 15:13:37</datemodified>
    <dateiso>2012-10-12</dateiso>
    <module>Misc</module>
    <project>P&amp;G Account Activities</project>
    <worktype>Holiday</worktype>
    <tasklocalid />
    <task />
    <firstname>Nikhil Talwar</firstname>
    <lastname>F00428</lastname>
    <active>t</active>
    <person>Nikhil Talwar F00428</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13111094</id>
    <projectid>328429</projectid>
    <moduleid>215560</moduleid>
    <taskid>2789914</taskid>
    <worktypeid>320912</worktypeid>
    <personid>135052</personid>
    <date>10/12/2012</date>
    <time>8</time>
    <description>Model Sanity Check and Creating Model Validation Template</description>
    <billable>t</billable>
    <datemodified>2012-10-06 04:02:57</datemodified>
    <dateiso>2012-10-12</dateiso>
    <module>Modeling</module>
    <project>Chartis - Consumer - Auto Ratemaking Model Validation</project>
    <worktype>Analyst (Offsite)</worktype>
    <tasklocalid>1468</tasklocalid>
    <task>Model validation</task>
    <firstname>Nikhil Yogesh Sheth</firstname>
    <lastname>F00669</lastname>
    <active>t</active>
    <person>Nikhil Yogesh Sheth F00669</person>
    <clientid>137305</clientid>
    <client>Chartis</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13185523</id>
    <projectid>335788</projectid>
    <moduleid>215564</moduleid>
    <taskid>2860738</taskid>
    <worktypeid>320912</worktypeid>
    <personid>135037</personid>
    <date>10/11/2012</date>
    <time>7</time>
    <description />
    <billable>t</billable>
    <datemodified>2012-10-11 05:59:36</datemodified>
    <dateiso>2012-10-11</dateiso>
    <module>Research, Study &amp; Review</module>
    <project>Chartis - LAD Research</project>
    <worktype>Analyst (Offsite)</worktype>
    <tasklocalid>5333</tasklocalid>
    <task>Review</task>
    <firstname>Dev Markandey</firstname>
    <lastname>F00577</lastname>
    <active>t</active>
    <person>Dev Markandey F00577</person>
    <clientid>137305</clientid>
    <client>Chartis</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13112184</id>
    <projectid>317186</projectid>
    <moduleid>209967</moduleid>
    <taskid />
    <worktypeid>326730</worktypeid>
    <personid>131100</personid>
    <date>10/11/2012</date>
    <time>8</time>
    <description />
    <billable>f</billable>
    <datemodified>2012-10-06 15:13:36</datemodified>
    <dateiso>2012-10-11</dateiso>
    <module>Misc</module>
    <project>P&amp;G Account Activities</project>
    <worktype>Holiday</worktype>
    <tasklocalid />
    <task />
    <firstname>Nikhil Talwar</firstname>
    <lastname>F00428</lastname>
    <active>t</active>
    <person>Nikhil Talwar F00428</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13111093</id>
    <projectid>328429</projectid>
    <moduleid>215560</moduleid>
    <taskid>2789914</taskid>
    <worktypeid>320912</worktypeid>
    <personid>135052</personid>
    <date>10/11/2012</date>
    <time>8</time>
    <description>Model Sanity Check and Creating Model Validation Template</description>
    <billable>t</billable>
    <datemodified>2012-10-06 04:03:06</datemodified>
    <dateiso>2012-10-11</dateiso>
    <module>Modeling</module>
    <project>Chartis - Consumer - Auto Ratemaking Model Validation</project>
    <worktype>Analyst (Offsite)</worktype>
    <tasklocalid>1468</tasklocalid>
    <task>Model validation</task>
    <firstname>Nikhil Yogesh Sheth</firstname>
    <lastname>F00669</lastname>
    <active>t</active>
    <person>Nikhil Yogesh Sheth F00669</person>
    <clientid>137305</clientid>
    <client>Chartis</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13185543</id>
    <projectid>316813</projectid>
    <moduleid>209831</moduleid>
    <taskid>2661059</taskid>
    <worktypeid>323668</worktypeid>
    <personid>131149</personid>
    <date>10/10/2012</date>
    <time>1</time>
    <description />
    <billable>t</billable>
    <datemodified>2012-10-11 06:04:20</datemodified>
    <dateiso>2012-10-10</dateiso>
    <module>Operations</module>
    <project>P &amp; G - HHC Global Home Care</project>
    <worktype>Develop model/template</worktype>
    <tasklocalid>280</tasklocalid>
    <task>SOI - US</task>
    <firstname>Apoorv Singhal</firstname>
    <lastname>F00539</lastname>
    <active>t</active>
    <person>Apoorv Singhal F00539</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13185542</id>
    <projectid>336901</projectid>
    <moduleid>209831</moduleid>
    <taskid>2874672</taskid>
    <worktypeid>323668</worktypeid>
    <personid>131149</personid>
    <date>10/10/2012</date>
    <time>4</time>
    <description />
    <billable>t</billable>
    <datemodified>2012-10-11 06:04:20</datemodified>
    <dateiso>2012-10-10</dateiso>
    <module>Operations</module>
    <project>P &amp; G - NA Market Diagnostic Project</project>
    <worktype>Develop model/template</worktype>
    <tasklocalid>5388</tasklocalid>
    <task>Market Diagnostic Report</task>
    <firstname>Apoorv Singhal</firstname>
    <lastname>F00539</lastname>
    <active>t</active>
    <person>Apoorv Singhal F00539</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    - <item>
    <id>13185541</id>
    <projectid>336901</projectid>
    <moduleid>209831</moduleid>
    <taskid>2874672</taskid>
    <worktypeid>323632</worktypeid>
    <personid>131149</personid>
    <date>10/10/2012</date>
    <time>2</time>
    <description />
    <billable>t</billable>
    <datemodified>2012-10-11 06:04:20</datemodified>
    <dateiso>2012-10-10</dateiso>
    <module>Operations</module>
    <project>P &amp; G - NA Market Diagnostic Project</project>
    <worktype>Data Pull</worktype>
    <tasklocalid>5388</tasklocalid>
    <task>Market Diagnostic Report</task>
    <firstname>Apoorv Singhal</firstname>
    <lastname>F00539</lastname>
    <active>t</active>
    <person>Apoorv Singhal F00539</person>
    <clientid>128266</clientid>
    <client>P&amp;G</client>
    <clientactive>t</clientactive>
    <statusid />
    </item>
    </time>
    </intervals>

  1.  

    They are being treated as string literals which is not a valid date. The following line is incorrect:

    URL url = new URL("https://api.myintervals.com/time/datebegin=datebegin&dateend=dateend&limit=1000");

    Needs to be changed to:

    URL url = new URL("https://api.myintervals.com/time/datebegin="+datebegin+"&dateend="+dateend+"&limit=1000");

    - Jaime

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