I am trying to build a service that provides parameters to query data, and then return a CSV file from the site.
The parameters include a deviceID, fromDate, and toDate.
I also need to create a mechanism to gain authorization to the site. The site requires that all API requests be authenticated via HTTP. The authentication elements include an email address, password, scheme identifier (which is specified as OHSC), the http request, date header, and content data.
There is a systematic way by which the authentication request has to be encoded via MD5, and BASE64, but I will leave that out for now.
For now, here is some confusion I need to resolve:
- How do I correctly create the HTTPClient, the HTTPRequestMessage, and the HTTP Date header?
- How do I incorporate that this will be a JSON request?
- How should the parameters required by the site be incorporated into the request?
Fiddler has returned the following sample request header:
GET /rawdata/exportRawDataFromAPI/?devid=3188&fromDate=01-24-2013&toDate=01-25-2013 HTTP/1.1
The following code snips are what I have been able to decipher to this point (Visual Studio 2012 .net 4.5):
HttpClient ServiceHTTPClient = new HttpClient();
SerivceHTTPClient.BaseAddress = new Uri(???????) //what is the uri address supposed to be?
ServiceHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Do I need to set variables for the three parameters, and include them in the URI?
Thank you for your help.