0
我試圖用的Sharepoint REST API(我們剛剛開始與SharePoint API,以便definitly沒有專家)來創建一個的ListItem。
按照微軟tutorial後應該是這樣的:
的SharePoint REST API返回錯誤請求(400)
我實現下面的代碼
public addItemToList_Test(): void {
var listTitle: string = "DemoHomeWork";
var listItemType: string = "SP.Data." + listTitle + "ListItem";
var listItemTitle: string = "TestItem";
var postBody = { '__metadata': { 'type': listItemType }, 'Title': 'TestItem' };
var $: jQuery = require("jquery");
var call = $.ajax({
url: listsUrl + "/GetByTitle('" + listTitle + "')/items",
method: "POST",
body: postBody,
headers: {
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
length: JSON.stringify(postBody).length
}
});
return call;
}
然而,這樣下去回我錯誤請求(400)並弄清楚爲什麼會發生這種情況是非常棘手的。有沒有人能告訴我這個請求有什麼問題?