0

Blizzard just shut down their old API, and made a change so you need an apikey. I changed the URL to the new api, and added the API key. I know that the URL is valid.

var toonJSON = UrlFetchApp.fetch("eu.api.battle.net/wow/character/"+toonRealm+"/"+toonName+"?fields=items,statistics,progression,talents,audit&apikey="+apiKey, {muteHttpExceptions: true})
var toon = JSON.parse(toonJSON.getContentText())

JSON.pase returns just an empty object

return toon.toSorce() // retuned ({})

I used alot of time to see if i could find the problem. have come up empty. Think it has something to do with the "responce headers".

Responce headers: http://pastebin.com/t30giRK1 (i got them from dev.battle.net (blizzards api site) JSON: http://pastebin.com/CPam4syG

Cœur
  • 37,241
  • 25
  • 195
  • 267
Meltinglava
  • 179
  • 1
  • 11

3 Answers3

0

I think it is the code you're using. I was able to Parse it by opening the raw url of your pastebin JSON http://pastebin.com/raw/CPam4syG And using the following code

var text = document.getElementsByTagName('pre')[0].innerHTML;
var parse = JSON.parse(text);

So to conclude I think it is the UrlFetchApp.fetch that's returning {}

Napoleon
  • 340
  • 3
  • 13
0

So i found the problems:

  1. I needed https:// in the URL since i found after some hours that i had an SSL error
  2. If you just use toString instead of getContentText it works. Thow why getContentText do not work, i am not sure of.
Meltinglava
  • 179
  • 1
  • 11
0

was same problem, this works for me (dont forget to paste your key)

var toonJSON = UrlFetchApp.fetch("https://eu.api.battle.net/wow/character/"+toonRealm+"/"+toonName+"?fields=items%2Cstatistics%2Cprogression%2Caudit&locale=en_GB&apikey= ... ")