Update a File in Document Library Using REST

  • 7 October 2019
  • 2 replies
  • 73 views

Im trying to use a Nintex Call HTTP web service to update a html file in a document library.

 

Per Microsofts https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest im using 

url: http://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')/$value
method: POST

body: "Contents of file."
Headers: Authorization: "Bearer " + accessToken
X-RequestDigest: form digest value
X-HTTP-Method:"PUT"
content-length:length of post body

 

The request is working however I am having an issue with the format of the request body. In the request body I simply need to pass in the raw html and nothing else. However due to the Call HTTP web service "request content" only accepting dictionary values I am having difficulty doing this.

4902i56150004C3F30B94.png

 

This is what is getting put into the file after the request 

 

4903iCC003B1640494B5F.png

 

All I want the requst to put in there is Hello World.


2 replies

Userlevel 3
Badge +9
Seems like a lot of complexity.
Why not use Nintex Workflow for O365's "Office 365 upload file"?
Here's the online help for it: https://help.nintex.com/en-US/O365/Default.htm#cshid=NLF80DDBC5F51D444B97BC69614485503B
First you'll need to create a connection using a service account with the desired permissions.

The O365 action works but in the content if we use workflow variables.it neglects the content and throws the exception " This file is empty and needs content to be uploaded. "


 


Has anyone found a workarounf for that

Reply