Skip to content

Instantly share code, notes, and snippets.

@Aymkdn
Last active January 2, 2019 17:17
Show Gist options
  • Save Aymkdn/19d7ca69c11a86d1656cd703aad3267d to your computer and use it in GitHub Desktop.
Save Aymkdn/19d7ca69c11a86d1656cd703aad3267d to your computer and use it in GitHub Desktop.
Post JSON using YQL Open Table
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Johannes Charman</author>
<description>JSON pages that need post data (this table is based on htmlpost by Christian Heilmann)</description>
<sampleQuery>select * from {table} where url='http://search.twitter.com/search.json' and postdata="q=test"</sampleQuery>
<documentationURL></documentationURL>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls>
<url>{url}</url>
</urls>
<inputs>
<key id="url" type="xs:string" required="true" paramType="variable"/>
<key id="postdata" type="xs:string" required="true" paramType="variable"/>
</inputs>
<execute>
<![CDATA[
var myRequest = y.rest(url);
var data = myRequest.accept('application/json').
contentType("application/json").
post(postdata).response;
response.object = <postresult>{data}</postresult>;
]]>
</execute>
</select>
</bindings>
</table>
@Aymkdn
Copy link
Author

Aymkdn commented Aug 3, 2017

Example:

use "https://gist.github.com/Aymkdn/19d7ca69c11a86d1656cd703aad3267d/raw/74d5802b5e6d4bceb4b39fbd120c53311b19623f/jsonpost.xml" as jsonpost;  
select * from jsonpost
   where url='https://web.site.com/api/v5/features/58236?access_token=e9cde433-7651-49a9-01fb0b4eee'
   and postdata="{over:rainbow,item:{description:'hello world'}}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment