0

Preventing YQL from URL encoding of key

I am wondering if it is possible to prevent YQL from URL encoding a key for a datatable?

Example: The updated guardian API works wit IDs like this:
item_id = "environment/2010/oct/29/biodiversity-talks-ministers-nagoya-strategy"

So If I now have this query
CODEBOX
SELECT * FROM guardian.content.item WHERE item_id='environment/2010/oct/29/biodiversity-talks-ministers-nagoya-strategy'


while using the following key defintion in my datatable
CODEBOX
<url>http://content.guardianapis.com/{item_id}</url>


then this results in this API call (see the URL encoding if item_id)
CODEBOX
http://content.guardianapis.com/environment%2F2010%2Foct%2F29%2Fbiodiversity-talks-ministers-nagoya-strategy?format=xml&order-by=newest&show-fields=all


Instead the guardian API expects the call to look like this:
CODEBOX
http://content.guardianapis.com/environment/2010/oct/29/biodiversity-talks-ministers-nagoya-strategy?format=xml&order-by=newest&show-fields=all


How can I achieve this? You can also check the full datatable:
http://github.com/spier/yql-tables/blob/ma...ontent.item.xml

by
2 Replies
  • Hey Hans, 

    I see you fixed this issue by using the execute block in your table.

    response.object = request.path(item_id).get().response;

    The other way to do this w/o using 'execute' is to simply change the key to paramType="path" which will insert it correctly into the path of the url.

    <key id="item_id" type="xs:string" paramType="variable" required="true"/> 

    Also - you would need to change your <url> node back to the way you had it:

    <url>http://content.guardianapis.com/{item_id}</url>

    Hope that helps in the future.

    stephen
    0
  • Does this mean that the way that the parameters are URL encoded has been changed?
    I have used paramType="path" in my inital test above, and it did not work, as the slashes in the parameter would get URL encoded.
    0
This forum is locked.

Recent Posts

in Y!OS Documentation