Why does HttpClient always give me the same answer?

Environment:
VS2012 Update 4
Windows Phone 8 SDK
new new Windows Phone project based on WP OS 7.1
NuGet pack1: MS Async
NuGet pack2: MS HttpClient


What the project does is
one test for the forum API:
to post a new topic on the forum and update JSON to check if the "score" is accumulating.


What the user interface means
enter image description here
1st text block:
json response will display here

3 :
[ JSON]: API1 [ ]: API2 ,
[IE]: json IE, API1

:
, , [New Post]


JSON
2
count: 244 --- >
"57923" --- > 1- ( "" )



1.
2. [ JSON],
3. "" "" 1-
4. [New Post], ,
5. [ JSON],
6. : "" 1, "title" ,


:
1. [New Post], , [ JSON], !

2. URL- Chrome (Desktop), , JSON !

3. , [ JSON], JSON , , ,


?



private async void RefreshJSONButton_Click(object sender, RoutedEventArgs e)
{
    this.JsonView.Text = string.Empty;
    HttpClient client = new HttpClient();
    string url =
        "API1 Address Here";
    string x = await client.GetStringAsync(url);
    this.JsonView.Text = x;
    client.Dispose();
}

private async void NewPostButton_Click_1(object sender, RoutedEventArgs e)
{
    Random rnd = new Random();
    this.num = rnd.Next(1, 99999);

    // generate the title and content with random number
    string threadTitle = this.num.ToString();
    string threadContent = "111" + num.ToString();

    // generate the url
    string url =
        "API2 Address Here";
    url = url + "&title=" + threadTitle + "&content=" + threadContent;

    // use HttpClient to send the new thread
    HttpClient client = new HttpClient();
    string x = await client.GetStringAsync(url);
    client.Dispose();

    // display the thread informartion for further check
    this.titleView.Text = threadTitle;
    this.contentView.Text = threadContent;
}
+1
1

, URL . Windows Phone .

, , . GUID Unix.

:

 private async void RefreshJSONButton_Click(object sender, RoutedEventArgs e)
    {
        this.JsonView.Text = string.Empty;
        HttpClient client = new HttpClient();
    int unixTimestamp = (int)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

    string url =
    "http://API1 Address Here/Your queries&temp=unixTimestamp";
    string x = await client.GetStringAsync(url);
    this.JsonView.Text = x;
    client.Dispose();
    }
+4

Source: https://habr.com/ru/post/1547547/


All Articles