Categories
General

How to Upload Documents using ConnectWise API

For the last couple of months, I have been using the ConnectWise API to integrate it with our custom software solution. It was fairly easy to add new companies, customers, tickets, and opportunities. Recently I was asked to add the ability to add documents. After reading the documentation, I was able to code the solution but it didn’t work as I expected. After many trials and errors, I was able to add documents using the ConnectWise API. In this post, I want to share my c# code to add system documents using ConnectWise API.

Here is the c# code to upload a document.

I hope that someone else can use this code and be able to upload documents. There is still room for improvement in ConnectWise’s system/upload documentation. The C# SDK does not have an upload sample code. I also want to mention that most of the c# code used to upload the document was taken from the internet. See you soon.

1 reply on “How to Upload Documents using ConnectWise API”

Hello Sir,
This code is very helpful as Connect wise has not provided the sample code or any kind of help for uploading document. Sir Iam stuck on some errors and have some confusion about the code:

public ResultsObject AddDocument (CRMParameters cp, Document doc)— (Its saying the namespace for CRMParameters and Document is not found).

FileStream fs = new FileStream(doc.FullPath, FileMode.Open, FileAccess.Read);— (And for this it is saying that cannot convert from system.io.Filemode to System.IO.FileAccess)
byte[] data = new byte[fs.Length];
fs.Read(data, 0, data.Length);
fs.Close();

Please help me with this.

Leave a Reply

Your email address will not be published. Required fields are marked *