I'm fairly new to developing SharePoint 2013 Apps, and I was tasked to customize the Create New Wiki Page for a Site. The user has to type in the Title, I do some processing, and then when everything is OK I create a new Wiki Page entry with the specified title.
What I have is the following code, which returns a Bad Request error:
executor.executeAsync(
{
url: appweburl + "/_api/web/GetFolderByServerRelativeUrl('/sites/doki/Wicky')/Files" +
"/AddTemplateFile(urlOfFile='" + filename + "',templateFileType=1)",
method: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest" : $("#__REQUESTDIGEST").val()
},
success: function (data) { alert('OK'); },
error: function (data, errorCode, errorMessage) {
alert('LOL FAIL ' + errorMessage);
}
}
);
I have the basic List CRUD using JavaScript and CSOM but it does not work on a Wiki Library. How can I create a new Wiki page entry with a specified title using JavaScript and either CSOM or REST? (whichever works better)