core icon indicating copy to clipboard operation
core copied to clipboard

constants/heroes returns inconsistent json format

Open DarkEyeDragon opened this issue 3 years ago • 4 comments

I spent the last half hour trying to figure out why my json parser wasn't able to convert the response based on the types i provided for it. Turns out the json returned in the browser is different from the one returned when requesting it through my application.

https://api.opendota.com/api/constants/heroes in browser returns a single object with key : value pair of hero objects while requesting it from code results in https://pastie.io/dvztnc.json an array of hero objects

DarkEyeDragon avatar Jul 25 '21 20:07 DarkEyeDragon

Hmm, I think we have to fix the docs, or the code that returns these. But either way, you can also request them from github

howardchung avatar Jul 26 '21 03:07 howardchung

It seems to leave out a lot of data as well. I have no way to recreate this however. It returns fine using wget, curl etc, its just when requesting it through my application (written in C#) that it seems to get a different response image Edit: Note that this is just the json response gotten by the httpclient, nothing is parsed yet.

DarkEyeDragon avatar Jul 30 '21 16:07 DarkEyeDragon

If it's correct with wget/curl the issue is something going on with your C# application or http lib

howardchung avatar Jul 31 '21 06:07 howardchung

If it's correct with wget/curl the issue is something going on with your C# application or http lib

Yeah thats what i initially thought too, but if i request it directly from github i get the correct response so i'm really confused

DarkEyeDragon avatar Jul 31 '21 16:07 DarkEyeDragon