Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How to Store XML Results from a RESTful HTTPWebRequest?

$
0
0

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.


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>