Random bad request error when starting to get data from the API — Guild Wars 2 Forums

Random bad request error when starting to get data from the API

Thiraz.4279Thiraz.4279 Member ✭✭
edited June 30, 2018 in API Development

My web app used to work fine for weeks and suddently I get bad request errors when getting data from the API.

I usually get an error between the second and the 5th pages requested. It happens on the production server and in my home development environment.

Here is the website:
http://gw2priceanalyzer.azurewebsites.net/

Here is the code to get the data:

    public static IQueryable<Item> ListItemDetails { get; private set; }
    public static IQueryable<Price> ListPriceDetails { get; private set; }

    public static async Task<bool> GetData()
        {
            using (var webClient = new WebClient())
            {
                 var tempPrices = new List<Price>();
                 var tempItems = new List<Item>();
                 var jsonData = await webClient.DownloadStringTaskAsync("https://api.guildwars2.com/v2/commerce/prices/");
                 var listItems = JsonConvert.DeserializeObject<List<int>>(jsonData);
                 var totalPagesCount = listItems.Count / 200;
                 for (var pageCount = 0; pageCount <= totalPagesCount; pageCount++)
                 {
                       jsonData = await webClient.DownloadStringTaskAsync($"https://api.guildwars2.com/v2/commerce/prices?page={pageCount}&page_size=200");
                       tempPrices.AddRange(JsonConvert.DeserializeObject<List<Price>>(jsonData));
                       jsonData = await webClient.DownloadStringTaskAsync($"https://api.guildwars2.com/v2/items?page={pageCount}&page_size=200");
                       tempItems.AddRange(JsonConvert.DeserializeObject<List<Item>>(jsonData));
                  }
                  ListPriceDetails = tempPrices.AsQueryable();
                  ListItemDetails = tempItems.AsQueryable();
            }
        return true;
    }

Comments

  • Wanze.8410Wanze.8410 Member ✭✭✭

    The Wiki has a warning atm:

    The Guild Wars 2 API is experiencing difficulties this weekend, which may affect various pages on this wiki such as Dailies, Trading post prices and Maps.

  • Thiraz.4279Thiraz.4279 Member ✭✭

    thank you for the information :)

  • Thiraz.4279Thiraz.4279 Member ✭✭

    It fixed by itself :)

©2010–2018 ArenaNet, LLC. All rights reserved. Guild Wars, Guild Wars 2, Heart of Thorns, Guild Wars 2: Path of Fire, ArenaNet, NCSOFT, the Interlocking NC Logo, and all associated logos and designs are trademarks or registered trademarks of NCSOFT Corporation. All other trademarks are the property of their respective owners.