I'm using the following method to write to a SharePoint list using REST with data from a HTML form. How can I modify it to also be able to also upload a files from the form? Thank you.
jQuery.ajax({
url: "https://.../_api/web/lists/GetByTitle('SupportTracker')/items",
method: "POST",
data: JSON.stringify({
'__metadata' : {'type': 'SP.Data.SupportTrackerListItem'},
'Title': title,
'Network': network,
'Enclave': enclave,
'Application': application,
'User_x0020_Account': sysuseracct,
'POC_x0020_Name': pocname,
'Problem_x0020_Type': problemtype,
'DTGStart': dateissuebegan,
'Details': details,
'POC_x0020_Phone_x0020_Number': pocnumber,
'POCEmailAddress2': pocemail,
'AssignedTo': assignedto,
'Ticket_x0020_number': externaltt
}),
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": formdigest
},
success: function(data) {
console.log("entry created successfully...");
},
error: function(data) {
//console.log("#__REQUESTDIGEST".val());
console.log("Error message: " + JSON.stringify(data.responseJSON.error));
}
});