I'm writing a C# console application that calls an HTTP RESTful web service which requires user name, password and token. It returns either XML or JSON as it's response. Thus far, I've written the following in my console application:
namespace GetPayroll { class Program { static void Main(string[] args) { Uri serviceUri = 'http://shiftplanning.com/api'; WebClient downloader = new WebClient(); downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(downloader_OpenReadCompleted); downloader.OpenReadAsync(serviceUri); } void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { if (e.Error == null) { Stream responseStream = e.Result; } } }
How do I pass in the user name, password and token as part of the request?
When the XML response is received, what must be done to serialize and parse the XML into a file on the local machine?
Thanks much for your help and guidance.