1

I am trying to update the fields of a just uploaded SharePoint document.

To upload the file, I POST to the following endpoint:

"_api/web/GetFolderByServerRelativeUrl('/{0}DropOffLibrary')/Files/add(url='{1}',overwrite=true)"

I then GET the file after uploading is complete:

"_api/web/GetFileByServerRelativeUrl('/sites/dodrc/DropOffLibrary/{0}')/ListItemAllFields", fileName

Where I'm struggling is in updating the fields of the uploaded file.

"_api/web/GetFileByServerRelativeUrl('/sites/dodrc/DropOffLibrary/" + fileName + "')"

I have tried to MERGE a slightly modified JSON object, and a SharePoint file model (with updated fields), but I keep receiving bad request (400) error messages.

I have also attempted to Google my question, but I'm not finding much in the way of useful results.

Any help would be much appreciated!

1 Answer 1

0

For updating you can do a POST request to /_api/web/GetFileByServerRelativeUrl('fileurl')/ListItemAllFields

The body should be something like

body: { '__metadata': { 'type': 'SP.Data.DocumentsItem' }, 'FieldName': 'FieldValue' }

Along with header X-HTTP-Method: MERGE

1

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.