0

Using fiddler to observe this URL: http://opencaselist.paperlessdebate.com/bin/AllDocs?view=attachments#format=json?|t=allattachments&p=1&l=10&s=filename&d=asc

I find a nice JSON response like this enter image description here

How do I get this response into a string that I can save in a txt file using C#? Is there a way to turn an HTTP Web Response to a string? Is there something is NewtonSoft JSON that can help me? Are there particular terms that will help me google this more effectively?

Every time I try I just get an HTML version of the web-page at the link and not the JSON data I'm trying to get:

    string url = "http://opencaselist.paperlessdebate.com/bin/AllDocs?view=attachments#|t=allattachments&p=1&l=10&s=filename&d=asc";

    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    httpWebRequest.Method = WebRequestMethods.Http.Get;
    httpWebRequest.Accept = "text/json";
    httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
    response.Close();
1

1 Answer 1

4

Note that on that screenshot, there are some differences:

  • the URL is way different: AllAttachements vs AllDocs, but that's minor, I'm pointing it out "just in case"
  • the PARAMS are way different: the screenshot specifies xpage=plain&outputSyntax=plain and your code - not
  • the HEADERS are different: your code has Accept=text\json while screenshot has Accept: text/javascript

Have you tried using the same params and headers?

EDIT: also, I've opened up the page from your code, and it actually is a page. After loading, it generates additional requests to

http://opencaselist.paperlessdebate.com/bin/get/XWiki/AllAttachmentsResults?xpage=plain&outputSyntax=plain&offset=1&limit=10&reqNo=1&sort=filename&dir=asc

which, if you download, results in JSON data. No headers at all, simple GET. I've just got the JSON data by simply pasting that URL into Chrome.. I think that you simply use wrong URL.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh. That makes a lot of sense - I just assumed that the URL fiddler was using was the same as the URL I was seeing in chrome. How you figured out my mistake so quickly is beyond me. I'm in awe.
Fiddler shows you all of the requests, including the AJAX requests, whose URLs are never shown in Chrome's address bar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.