Javascript API


(Mahearnpad) #1

Hi


I'm using the example of the implementation provided in the web services manual to create a standard page asset. The error returned is: "you are not allowed to create this asset type". Permissions on the parent asset are public read, and write and admin assigned to me (system administrator). Can you please tell me what else I need to do to get this to work?



One more question: I can see there is a method for setting metadata field values via the api. Is there any way to set the particular metadata schema first? In our case, we have several metadata schemas depending on what type of asset or area of the site is involved.



Thanks in advance

Michael


(Benjamin Pearson) #2

[quote]
The error returned is: "you are not allowed to create this asset type".

[/quote]



This error is because you are trying to create an asset type not listed on the details (under "Restrictions") of the JS API (and you have some set, by leaving it blank you should be able to create any asset type).


(Anthony Barnes) #3

The JS API asset needs to be configured to allow asset creation (ie, 'Create Asset - Yes' - the default is No). If this is set, perhaps you have additional configuration to restrict asset type on create in the JS API Asset? Can you also tell us what version of Matrix you are using?


The metadata schema applied to an asset will inherit from it's parent, if you are creating a new asset. Currently there is no way to apply a metadata schema to an asset using the JS API, but you can tap into the SOAP API metadata service to achieve this via JavaScript.


(Mahearnpad) #4

Thanks Benjamin and Anthony for your replies. I've checked the 'restrictions' section on the details screen of the api asset, and there were no assets chosen (I'm assuming this means I could create anything?). And I've chosen 'yes' to everything else.


The version of matrix I'm using is 3.22.6.



Any other suggestions?


(Mahearnpad) #5

Problem solved - stupid really. Instead of passing 'page_standard' to the method, I was passing 'standard_page'.


(Anthony Barnes) #6

Considering the amount of development done with the JS API you might also be interested in taking a look at the change logs from your version to the latest. If you are implementing some javascript functionality/interface to your site then you will find significant features and fixes to the JS API in the latest stable.