0

In C#, I want to create a file in my SharePoint Online site without using SharePoint client object model.

I am trying to use SharePoint REST APIs and List methods.

I don't want to use Microsoft.SharePoint.Client as the use of this DLL requires installation of SharePoint Client Components on the client server.

Is there any way to solve this problem?

1

You can try this code in Javascript:

executor.executeAsync({
  url: "<app web url>/_api/SP.AppContextSite(@target)/web
    /getfilebyserverrelativeurl('/Shared Documents/filename.docx')
    /savebinarystream
    ?@target='<host web url>'",
  method: "POST",
  body: "This is the new content.",
  success: successHandler,
  error: errorHandler
});

It creates a file from the file system to your sharepoint online site. Kindly validate if this is the needed answer.

You can refer to this link for more informations : https://msdn.microsoft.com/en-us/library/office/dn450841.aspx#bk_FileSaveBinaryStream

  • Thank you. But, I am writing C# (plugin) code and not a JavaScript code. – Purva Sapre Mar 11 '15 at 13:27
  • You can try this link, there's an exemple of how to call REST service from C#. Can you give it a try ? – KhalilG Mar 11 '15 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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