Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read the XML-data from the simple tumblr API.

When opening e.g.:

https://demo.tumblr.com/api/read[^]

in your browser for the first time, you have to click on "Accept". Then you get the XML-data that I want to import into a small program.

A description of the API is here :
Tumblr API v1 | Tumblr[^]
so I know that the XML is limited to max. 50 entries and I know how to "iterate" over them by setting the start-parameter, but I am not even able to get the inital 20 entries.

What I have tried:

I tried several things so far. My latest version is:

C#
string strURL = "https://demo.tumblr.com";
            
WebClient wClient = new WebClient();
wClient.Encoding = System.Text.Encoding.ASCII;
wClient.BaseAddress = strURL;

//Read for the first time            
string strData = wClient.DownloadString("/api/read");
            
if (strData.StartsWith("<!DOCTYPE html>"))
{
     var nvcAgree = new System.Collections.Specialized.NameValueCollection
     {
       {"btn_yes", "agree" }
     };

     //Click on "Accept" and read the second time
     strData = Encoding.ASCII.GetString(wClient.UploadValues("/api/read", nvcAgree));



    /*
    Here will be code to repeatedly open the website as the XML is limited to
    50 entries
    */

     this.textBox1.Text = strData;
                
}


Unfortunately this does not work and I am always getting the html-data for the "disclaimer" to be accepted.


Any help is appreciated!

Cheers
Daniel Roerick
Posted
Updated 3-Dec-19 19:02pm

1 solution

check with Encoding as UTF8 and set headers.
WebClient wClient = new WebClient();
wClient.Headers["Content-type"] = "text/xml";
wClient.Encoding = Encoding.UTF8;
 
Share this answer
 
v3
Comments
Daniel Roerick 4-Dec-19 16:35pm    
Unfortunately this does not help! I meanwhile doubt whether I "clicked" the button correctly.

I examined the button (with Firefox) and it says

Accept

Although I deleted the underscore in my NameValueCollection it does not work ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900