Search code examples
jsondiscordget-request

Not sure why my JSON file is appearing as random characters, could use help getting it to readable text


Output of json string

Hello everyone, I'm working on creating a discord bot for an rp forum I'm on and basically trying to make an automatically updating members list by using web scraping. The web scraper im using is called ParseHub, and it has an api which allows you to pull the collected data as a json. When I create a get request in postman it comes in perfectly readable, but when I try to implement this in my c# application the string that is returned is the output shown above. I'm pretty much brand new to working with http requests so chances are I've messed something up but the idea is to pull the list from the api. Below I've listed the code I've used so far and I've also linked the documentation to the api. (ive replaced the token and api key with basic text but other than that the url is how I believe it's supposed to look)

https://www.parsehub.com/docs/ref/api/v2/#run-a-project

[Command("RefreshLists")]
        public async Task RefreshLists(CommandContext ctx)
        {
            try
            {
                using (HttpClient httpClient = new HttpClient())
                {
                    using (var response = await httpClient.GetAsync("https://parsehub.com/api/v2/projects/tokengoeshere/last_ready_run/data?api_key=apikeygoeshere&format=json"))
                    {
                        if (response != null)
                        {
                            var responseString = await response.Content.ReadAsStringAsync();
                            Console.WriteLine(responseString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

Solution

  • Never mind, solved it. The issue was with gzip compression.