我可以使用GET方法发出请求并使用数据,但现在我需要在SharePoint中创建一个html表单并使用javascript提交到SharePoint列表。有什么帮助吗?
PostFormBuilder.RESTPost = function (listTitle, query) {
var execute = function (listTitle, query) {
var restUrl = _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('" + listTitle + "')/items";
if (query != "") {
restUrl = restUrl + "?" + query;
}
var deferred = $.ajax({
url: restUrl,
method: "POST",
body: { '__metadata': { 'type': 'SP.Data.Modelo' }, 'Title': 'Test'},
headers: {
Authorization: "Bearer " + accessToken,
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-Http-Method": "MERGE"
}
});
return deferred.promise()
};
return {
execute: execute
}
}();