Making JS API calls from a REST Resource JavaScript


(Iain Simmons) #1

Hi,

 

Basically, I'm trying to create some sort of automated asset creation system that will bring in items from an RSS feed and create assets in Matrix.

 

I'm using a REST Resource JavaScript to grab a blog RSS feed and can use that to display particular items based on a timestamp (i.e. newer than a particular Unix timestamp).

 

Now I'd like to make calls to the JavaScript API to create assets with some of the attributes of the RSS feed items.

 

If I try to include the JavaScript API asset as one of the 'Include Files' of the JavaScript Processing area of the REST Resource JavaScript asset, I get the following error in the error log:

PHP Fatal error: Call to undefined method JS_Api::getExistingFile() in /[SYSTEM_ROOT]/packages/web_services/rest/page_templates/page_rest_resource_js/page_rest_resource_js.inc on line 99

I suspected that it had something to do with it not being a 'JS File' asset, so I created one with the actual JS code of the JavaScript API and removed the scope stuff and that will load it, but then when trying to make JavaScript API calls (with the enhanced JS API), there is a MySource Notice in the error log, and the script stops processing when it tries to send the request:

(/packages/web_services/rest/page_templates/page_rest_resource_js/page_rest_resource_js.inc:171) - Page_REST_Resource_JS (#[Asset ID]) uncaught exception: Your browser does not support Ajax

Anyone have any ideas how I can combine these two very useful asset types?

 

- iain