Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieve content from 404 error using HttpWebRequest
    primarykey
    data
    text
    <p>This is similar to a question asked here: <a href="https://stackoverflow.com/questions/10311582/httpwebrequest-get-error-content">httpWebRequest - get error content</a> but I'm hoping to provide some more information in hope of an answer.</p> <p>I am integrating with the LinkedIn API using C#. When I make an <strong>invalid</strong> call to the API, it can return a HTTP response like such (from Fiddler):</p> <pre><code>HTTP/1.1 404 Not Found Server: Apache-Coyote/1.1 x-li-request-id: VL2EER2ROJ Date: Tue, 16 Oct 2012 08:52:59 GMT Vary: * x-li-format: xml Content-Type: text/xml;charset=UTF-8 Content-Length: 266 &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;error&gt; &lt;status&gt;404&lt;/status&gt; &lt;timestamp&gt;1350377580000&lt;/timestamp&gt; &lt;request-id&gt;VL2EER2ROJ&lt;/request-id&gt; &lt;error-code&gt;0&lt;/error-code&gt; &lt;message&gt;Could not find member {/people/XXXXXX}&lt;/message&gt; &lt;/error&gt; </code></pre> <p>I would specifically like to get at the error xml, however HttpWebRequest seems to simply throw the exception and then has nothing to do with the content. In my debugger, I can see that the content length is 266, but any attempt to call <code>(System.Net.WebException).Response.GetResponseStream()</code> results in a <code>stream was not readable</code> exception.</p> <p>This method of returning error messages within a non 200 HTTP status response seems quite popular in web APIs - I'm hoping there is a way to get at these responses...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload