This method is to be used to attach documents to lease or work order records.
Request
Data is added by performing a HTTP Post to https://api.myresman.com/Documents/Attach supplying the listed parameters below.
Parameters
Name | Description | Example | Required |
IntegrationPartnerID | The ID assigned to your company by ResMan | 1000 | Yes |
ApiKey | The API key assigned to your company by ResMan | 09C9ED27F53F4748A… | Yes |
AccountID | The AccountID associated with the property | 400 | Yes |
PropertyID | The PropertyID associated with the property | 07413576-f764-44c6-be35-df4139deec01 | Yes |
RecordID | The ProcessorTransactionID, LeaseID, WorkOrderID, Unit number, or UnitID (Guid) of the lease or work order to tie the document to. | 4B720E1A-DF9B-496D-9059-21F3668F22FF | Yes |
RecordType | The type of record to tie the document to. Possible Values: WorkOrder, Lease, Unit, ProcessorPayment | Lease | Yes |
FileName | The name of the document | document.pdf | Yes |
URL | the URL of the document, if it is hosted online | http://www.images.com/document.pdf | No |
Documents can be attached either by passing in a URL parameter or by posting a file as a byte array, in addition to the other parameters.
The following demonstrates one way of attaching a document to a Lease by sending a byte array using C#:
string url = "https://api.myresman.com/Documents/Attach";
HttpWebRequest requestToServerEndpoint = (HttpWebRequest)WebRequest.Create(url);
string boundaryString = "----SomeRandomText";
string fileUrl = @"C:\Temp\Lease_Document.png";
requestToServerEndpoint.Method = WebRequestMethods.Http.Post;
requestToServerEndpoint.ContentType = "multipart/form-data; boundary=" + boundaryString;
requestToServerEndpoint.KeepAlive = true;
requestToServerEndpoint.Credentials = System.Net.CredentialCache.DefaultCredentials;
MemoryStream postDataStream = new MemoryStream();
StreamWriter postDataWriter = new StreamWriter(postDataStream);
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"IntegrationPartnerID",
"1000");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"ApiKey",
"09C9ED27F53F4748AF767DA699A417A2");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"PropertyID",
"07413576-f764-44c6-be35-df4139deec01");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"AccountID",
"400");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"RecordID",
"A0FEFDEC-883C-42F2-95FB-4E21B403A126");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"RecordType",
"Lease");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}",
"FileName",
"Lease_Document.png");
postDataWriter.Write("\r\n--" + boundaryString + "\r\n");
postDataWriter.Write("Content-Disposition: form-data;"
+ "name=\"{0}\";"
+ "filename=\"{1}\""
+ "\r\nContent-Type: {2}\r\n\r\n",
"Content",
Path.GetFileName(fileUrl),
Path.GetExtension(fileUrl));
postDataWriter.Flush();
FileStream fileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
{
postDataStream.Write(buffer, 0, bytesRead);
}
fileStream.Close();
postDataWriter.Write("\r\n--" + boundaryString + "--\r\n");
postDataWriter.Flush();
requestToServerEndpoint.ContentLength = postDataStream.Length;
using (Stream s = requestToServerEndpoint.GetRequestStream())
{
postDataStream.WriteTo(s);
}
postDataStream.Close();
WebResponse response1 = requestToServerEndpoint.GetResponse();
StreamReader responseReader = new StreamReader(response1.GetResponseStream());
string replyFromServer = responseReader.ReadToEnd();
Response
When submitting a request to the Post method, you will receive a response following the pattern below. The response will include information about the method that was called as well as a status indicating whether or not the request was successful. If there was an error in the request, the ErrorDescription node will identify any problems with the request.
Below are examples of the response you can expect from this method.
XML Response
<ResMan>
<MethodName>Attach</MethodName>
<Status>Success</Status>
<AccountID>800</AccountID>
<PropertyID>4fb18691-c894-4b84-805b-c62da481ca63</PropertyID>
<Response>
<Document>
<DocumentID>664b453f-88a4-491b-8a57-7b4cbc924584</DocumentID>
<FileName>CheckImage</FileName>
<RecordID>133212584</RecordID>
<RecordType>ProcessorPayment</RecordType>
</Document>
</Response>
</ResMan>
JSON Response
{
"MethodName": "Attach",
"ErrorDescription": null,
"Status": "Success",
"AccountID": 400,
"PropertyID": "07413576-f764-44c6-be35-df4139deec01"
"DocumentID": "664b453f-88a-491b-8a57-7b4cbc924cbc924584"
"FileName": “Checkimage”
"RecordID": “133212584”
"RecordType": “ProcessorPayment”
}
Possible Errors
If any errors occur while adding the documents, they will be returned in the ErrorDescription node, which contains a list of error messages logged while parsing the work orders.
The following errors will be logged and returned: