0

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));
            }
        });

1 Answer 1

0

NO,you can't upload file and set column value in one request.
Similar issue for your reference:
REST post with metadata column?
https://stackoverflow.com/questions/45175323/sharepoint-2013-online-can-i-set-other-column-values-when-uploading-a-file-using

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.