Hi,
I just integrated Intarvals API with Microsoft NAV 2009, i have successfully received all the data (Time) and then i insert them in a table of Nav.
I'd like to know: Is possible can mark items that i read/downloaded?
Because if in future I will make another request, I would not read&download data already in the table.
Is possible create a new item xml: <read> yes or no </ read> in the structure XML received from Interval?
Did you have some suggestion?
Thanks for your attention.
Lorenzo
Is it possible to record the date and time of the last request? If that is possible that value can be used on subsequent API requests.
The next API request can use the filter datebegin with the value being the date and time of the last request. This results in only receiving the time entries that are new since the last request.
The URL would look something like:
https://api.myintervals.com/time/?datestart=2012-06-29 06:00:00
Hi LorenzoB
I'm thinking about doing the same, integration NAV with Intervals. I haven't started the project, but I was planning on having it as a summer project. Are you interested in sharing you codeunits etc. to get me started? Later we could share the experience we both gain.
Regards
Jacob Bang
thanks jprado
it was the first idea that I too have had to filter through datebegin and dateend, in fact, is what I did. But the problem remains because the request via GET does not support the filter "Datemodified" and so you lose all items older but changed after the databegin.
@Webemil
I created:
1. TABLE where to save the data;
2. CODEUNIT for API communication;
3. XMLport to bring the received XML data in the table;
4. a PAGE to filter data and run the codeunit.
I'll leave the heart of codeunit:
// initializations var
CREATE(XmlHttp); :'Microsoft XML, v6.0'.XMLHTTP60";
CREATE(XmlOut); :'Microsoft XML, v6.0'.DOMDocument";
CREATE(XmlIn); :'Microsoft XML, v6.0'.DOMDocument";
//Create URL
datebeginUrl := FORMAT(datebegin,0,'<Year4>-<Month,2>-<Day,2>');
dateendUrl := FORMAT(dateend,0,'<Year4>-<Month,2>-<Day,2>');
newUrl := 'https://api.myintervals.com/time/?datebegin='+datebeginUrl+'&dateend='+dateendUrl+'&limit=0';
// Communication
XmlHttp.open('GET',newUrl,FALSE);
XmlHttp.setRequestHeader('content-type','text/xml');
XmlHttp.setRequestHeader('Accept','application/xml');
//XmlHttp.setRequestHeader('KeepAlive','true');
XmlHttp.setRequestHeader('Timeout','60000');
// Autentication
myEncoding := myEncoding.ASCIIEncoding();
myToken := 'XXXXXXXX';
myToken := myConvert.ToBase64String(myEncoding.GetBytes(myToken));
XmlHttp.setRequestHeader('Authorization', 'Basic '+myToken);
// Send request
XmlHttp.send();
// Get response
XmlOut.async := FALSE;
XmlOut.load(XmlHttp.responseXML);
//Save File
IF EXISTS('C:\Temp\XML\XML_Time.xml') THEN
ERASE('C:\Temp\XML\XML_Time.xml');
XmlOut.save('C:\Temp\XML\XML_Time.xml');
//remove namespaces because the XMLport not digest them input
RemoveNamespace(XmlOut,XmlOut);
//XMLPort
TimeTable.DELETEALL;
TimeFile.OPEN('C:\Temp\XML\XML_Time.xml');
TimeFile.CREATEINSTREAM(TestStream);
XMLPORT.IMPORT(90004,TestStream);
TimeFile.CLOSE;
MESSAGE('XMLPort complete');
CLEAR(XmlHttp);
1 to 4 of 4
Comments are closed.
For more Intervals help documentation, please visit help.myintervals.com