Hi Guys,
I am trying to create assets (standard page) using JS API. Basically I took this (Standard Mode) code https://manuals.matrix.squizsuite.net/web-services/chapters/basic-javascript-api-implementation
and converted it into something like this ....
<script type="text/javascript" src="./?a=10001"></script> <script type="text/javascript"> function setApiKey(api_key) { // Make this into a global variable window.api_key = api_key;}//end setApiKey
function printObject(object) {
console.log(“Asset created successfully”);
}
// Function to retrieve parent id and file name from URL
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
function matrixCreateAsset() {
var parent = getQueryVariable(“pid”); // Get Parent Id from pid in URL
var type = “standard-page”;
var name = getQueryVariable(“filename”); // Get file name from filename in URL
//var name = “myfile5”;
var val = “some-value”;
console.log(parent,name); // For debugging
createAsset(parent, type, name, 1, val, -1, 0, 0, 0, 0, printObject);
}
setApiKey(123456789);
matrixCreateAsset();
</script>
And then I was hoping that this code will create a "Standard Page" asset by passing "parent id" and "file name" in the URL like this ....
https://mywebsite.com/test-site/create-pages-using-get?pid=51047&filename=myfile7
But nothing is happening, no error, nothing ....
console.log is printing correct pid and filename values ....
Any help is very appreciated ....
Thanks