Hi guys, I ran into an issue today with the returned response from the Tumblr API. Based on the answer to this post I might also post to the Tumblr API forum.
Basically what I am trying to do is create a Roku notification to the user if there is an issue with the API call, for any meta status other than 200. So the issue I need to describe is this: If I send a valid curl request in Mac Terminal to Tumblr to an inactive/unavailable domain, the JSON response comes back as:
{
"meta": {
"status": 404,
"msg": "Not Found"
},
"response": [
]
}
If I send the exact same curl URL using Roku, the ParseJSON function seems to break. I do have ParseJSON() running fine for a valid Tumblr account. I can pull data from the API no problem. For a valid account, I am able to access the meta status using:
json.meta.status
json.meta.msg
On Roku, I get a bright script error indicating the json object is invalid. To debug, if I print the data variable it comes up empty. If I print the json variable it comes up 'invalid'. This JSON response above looks correct but I am not 100% sure.
Code:
xfer=CreateObject("roURLTransfer")
xfer.seturl(url)
data=xfer.gettostring()
json = ParseJSON(data)
xfer &h0010 bsc:roUrlTransfer, refcnt=1
data &h8010 bsc:roString (2.1 was String), refcnt=1
json &h0080 Invalid val:invalid
Any tips are appreciated 🙂 Thanks