YQL ODT - REST GET response exists but inaccessible

淺唱寂寞╮ 提交于 2019-12-25 02:35:07

问题


I am writing an Open Data Table to aggregate like counts from various social networking services.

My attempt can be found here at the YQL console, with the Open Data Table XML being here.

My current problem - as you will find out on trying my query - is that Twitter and Facebook's requests return an empty response object with:

org.mozilla.javascript.UniqueTag@399a063e: NOT_FOUND

instead of populating it with the JSON that each respective service returns.

I think that the non-zero content-length header returned in the rest object indicates that the YQL server has received the correct JSON reply, and thus the problem isn't on the web services' sides but on either YQL's or my ODT's side.

I have tried to solve this problem in various ways and have been unsuccessful. Could some YQL experts please help me out?

Thank you.


回答1:


I have found my solution and this may be a bug in the YQL server.

What happens is that when a web service returns content with content-type 'application/json', YQL parses it into the E4X format, an xml representation for JavaScript. Why it does so, I do not have any clue on since JSON should be parsed into a JavaScript object.

The problem with this E4X format seems to be that it is only accessible within the optional callback function that can be supplied when calling y.rest().

When trying to store bits of data into a variable, and apply it to the response.object object, I found that the console would return a NOT FOUND error. This means that what I thought I had stored into my variables was not a string or integer value for these social button counts, but a reference to an E4X node.

To solve this problem, I performed parseInt magic on the node to get my numbers.

I believe this behaviour is very odd and is most likely an unintended bug. Hopefully, a developer will pick up on this issue to prevent future confusions.



来源:https://stackoverflow.com/questions/9706643/yql-odt-rest-get-response-exists-but-inaccessible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!