Search code examples
http-headershttpclienthttpresponse

Response Spectrum - how to get data from website


Please is anybody help me or at least explain, how it works...

It's about this website: http://mpk.wroc.pl/jak-jezdzimy/mapa-pozycji-pojazdow

when click on F12, we can seeing, that we have

enter image description here

and if typing in cmd command, e.g.:

curl http://mpk.wroc.pl/position.php --data \
  "busList%5Btram%5D%5B%5D=31&busList%5Btram%5D%5B%5D=32"

it everythings works!

enter image description here

also is appears from "response" on developer mode.

enter image description here

but finally, when I wanted get data by Postman, setting POST and sending correct data (I think), it returns nothing...

also I tried made by C# by HTTPClient, WebClient, HttpWebRequest/Response etc. and nothing, I can't found any data...


Solution

  • This works for me: Create new Postrequest in postman to http://mpk.wroc.pl/position.php Change body keyvalues in x-www-form-urlencode.

    http://prntscr.com/le1deh

    EDIT

    To implement this in C# you can do something like this:

        static void Main(string[] args)
        {
            Dictionary<string, string> formvalues = new Dictionary<string, string>();
            formvalues.Add("busList[bus][]", "114");
            FormUrlEncodedContent body = new FormUrlEncodedContent(formvalues);
            sendPost(body);
            Console.ReadKey();
        }
    
    
        static async void sendPost(FormUrlEncodedContent content)
        {
            HttpClient client = new HttpClient();
            HttpResponseMessage response = await client.PostAsync("http://mpk.wroc.pl/position.php", content);
            string responseString = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseString);
        }