I want to get time entries of Freckle using its API for some specific dates, but either I get 404 – Not Found and when I change the formation of URL it generates 406 – Not Acceptable. And when I want to access them without using the date filter It works fine. The URI I am sending for date filter is:
string dFilter = @"\ -data'search[from]=2012-07-05'";
string uri = @"https://apitest.letsfreckle.com/api/entries.xml"+dFilter;
webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Headers.Add("X-FreckleToken:lx3gi6pxdjtjn57afp8c2bv1me7g89j");
webRequest.Method = "GET";
WebResponse webResponse = webRequest.GetResponse();
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
responseXML = sr.ReadToEnd();
can you tell me how to use this date Filter correctly? The Documentation of API can be found at:
Documentation
Thanks in advance.
I think the problem is that you’re including the filter in the URL using a space and command line options which are part of a
curlcommand.The documentation shows things like:
There the
\is a line continuation, and-dis used to pass data for the request. The quotes are just to keep it all in one parameter for the shell. The-Gsays to still use aGETrequest though, and put the data in the URL… but it’s not quite as you’ve done it. Try this:(Also note that you ought to use a
usingstatement for theWebResponseand theStreamReader.)