>Hi
>
>I've got some code that accesses a REST web service to get authorisation and then get a token.
>
>The line XDocument doc = XDocument.Load(stream);
>
>returns an error
>
>'doctype' is an unexpected token. The expected token is 'DOCTYPE'
>
>How can I see the contents of the response stream and why would I get that error ?
>
>Thanks
>
>
>HttpWebResponse response = ProfileSampleApp.httpWrapper.getAccessToken(accessTokenURL);
>string token = Utils.getElementValue("Token",response.GetResponseStream());
>
>public static string getElementValue(string elementName,Stream stream)
> {
> XDocument doc = XDocument.Load(stream);
> return (from element in doc.Descendants(elementName)
> select element).Single().Value;
> }
Sounds as if the incoming is using 'doctype' and the parser is insisting on the upper case version.
You could use Fiddler to see what's coming in. If it is 'doctype' then maybe you could get the stream into a string, adjust the value and then use XDocument.Load() with the TextReader option ?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only