Application & Process Automation

Getting Started
Authentication & Access
Accounts with Multi-Factor Authentication
Using method GetPrograms
Common Usage Scenarios
Create and Submit a Project
Add/Change Data in an Existing Project
Daily Polling for Project Changes
Troubleshooting
Using Custom IDs
API Method Reference
GetPrograms
URL Format
Response
XML Attributes
Sample Code
GetForms
URL Format
Response
Forms Attributes
AvailableInStatuses and LeadsToStatus
Status Attributes
Sample Code
GetFormSchema
V1 Response
V2 Response
Sample Code
GetProjects
V1 Response
V2 Response
V3 Response
Sample Code
GetProjectsByNumber
V1 Response
V2 Response
Sample Request
Sample Code
GetProjectsByData
Sample Request
Request XML Nodes and Attributes
V1 Response
V2 Response
CreateNewProject
Sample Response
Response XML Attributes
Sample Code
GetAllProjectData - Admin only
Sample Response
XML Attributes
Sample Code
GetProjectData
Sample Response
XML Attributes
Sample Code
SetProjectData
Sample Request
Request XML Attributes
Sample Response
Response XML Attributes
Sample Code
GetActiveAttachment
URL Format
Sample Code
GetAttachmentAsAdmin – Admin only
URL Format
SetProjectAttachment
Identifying attachment file types
URL Format
Sample Response
Response XML Attributes
Sample Code
SetAttachmentMetadata
Sample Request
Request XML Attributes
Sample Response
Response XML Attributes
Sample Code
GetAttachmentMetadata
URL Format
Sample Response
Response XML Attributes
Sample Code
SubmitProject
URL Format
Sample Response
Response XML Attributes
Sample Code
GetStatusList – Admin only
Sample Code
URL Format
Sample Response
Response XML Attributes
GetCustomListChoices
URL Format
Sample Response
Response XML Attributes
GetProjectStatusHistory – Admin only
URL Format
Sample Response
Response XML Attributes
Sample Code
SetProjectStatus – Admin only
URL Format
Sample Response
Response XML Attributes
Sample Code
GetExportProject – Admin only
Response XML Attributes
Sample Code
URL Format
Sample Response
CreateMfaSessionToken
URL Format
Sample Request
Request XML Attributes
Sample Response
Response XML Attributes
Sample Code
DeleteMfaSessionToken
URL Format
Sample Response
Sample Code
SetAssignee
URL Format
Sample Request
Request XML Attributes
Sample Response
Response XML Attributes
SetProjectOwner
URL Format
Sample Request
Request XML Attributes
Sample Response
Response XML Attributes
GetInquiryThreads – Admin Only
GetNotesInInquiryThread – Admin Only
SetInquiryNote – Admin Only
SetInquiryThreadStatus – Admin Only
SetInquiryThreadExternalId – Admin Only
SetProjectStatusReportAs – Admin only
Code Samples
EncodeAuthorizationHeader
MakeGetRequest
MakePostRequest
MakeGetFileRequest
MakeDeleteRequest
PowerShell

SetProjectAttachment

Uploads a file attachment for the given project. Requires write access to the project.
 
HTTP verb: POST
Required inputs: ProgramId, ProjectId, FormId, AttachmentId

Identifying attachment file types via headers

PowerClerk supports uploading of the types to project forms based on configured attachment definitions. The default Content-Types that can be used must be set as follows in the request (Please use for any other allowed attachment file extension “application/octet-stream” as the Content-Type Request Header value):
 

FileType Content-Type Request Header value
.pdf application/pdf
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.csv text/csv
.zip application/zip
Any other custom defined attachment extensions application/octet-stream

 
The optional Content-Disposition header can be set to convey the filename in the filename tag.
Sample header value: attachment; filename="filename.pdf"
If there is no filename, PowerClerk will generate one.

URL Format

Format: https://{BaseURL}/Programs/{ProgramId}/Projects/{ProjectId}/Forms/{FormId}/Attachments/{AttachmentId}/Upload
 
Sample: https://{BaseURL}/Programs/A43FN6B/Projects/D4GJR65/Forms/47LEZF8/Attachments/87GR2F3/Upload
 
Sample if the form has a custom ID of “MyForm” and the attachment has a custom ID of “MyAttachment”:
https://{BaseURL}/Programs/A43FN6B/Projects/D4GJR65/Forms/MyForm/Attachments/MyAttachment/Upload
 

Sample Response


<AttachmentSetResponse>
    <Attachment AttachmentId="3QX3VQ18" CustomId="MyAttachment" Name="Copy Of Utility Bill" FileName="utility-bill.pdf" />
</AttachmentSetResponse>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://service.powerclerk.com/api/v1/">
  <xs:element name="AttachmentSetResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Attachment">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute type="xs:string" name="AttachmentId" use="required"/>
                <xs:attribute type="xs:string" name="CustomId" use="optional"/>
                <xs:attribute type="xs:string" name="Name" use="required"/>
                <xs:attribute type="xs:string" name="FileName" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute type="xs:float" name="SchemaVersion"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Response XML Attributes

<Attachment> Attributes

AttachmentId – Unique identifier for the attachment
CustomId – administrator-set, unique identifier for the attachment
Name – Attachment name
FileName – Attachment filename

Sample Code


// For a given project's application form, upload a PDF file as a utility bill attachment.
// Returns true if the upload completed successfully, false otherwise.

public bool UploadUtilityBill(string programId, string projectId, string formId, string utilityBillAttachmentId, string filePath, string username, string password, string apiKey)
{
    // Retrieve the file and prepare it for uploading
    byte[] fileContents = File.ReadAllBytes(filePath);
    StreamContent payload = new StreamContent(new MemoryStream(fileContents));

	// Create the url for the upload
    string url = "/Programs/" + programId + "/Projects/" + projectId + "/Forms/" + formId +
"/Attachments/" + utilityBillAttachmentId + "/Upload";

    // Make POST request to upload the attachment
    XDocument xmlResponse = null;
    using (HttpClient webClient = new HttpClient())
    {
        string authHeader = EncodeAuthorizationHeader(username, password);
        string fileName = Path.GetFileName(filePath);

		payload.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
        {
            Name = "\"file\"",
            FileName = "\"" + fileName + "\""
        };
        string contentType = "application/pdf"; // pdf
        payload.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType);

		webClient.DefaultRequestHeaders.Clear();
        webClient.DefaultRequestHeaders.Add("Authorization", authHeader);
        webClient.DefaultRequestHeaders.Add("X-ApiKey", apiKey);
        using (HttpResponseMessage response = webClient.PostAsync(BaseUrl + url, payload).Result)
        {
            xmlResponse = XDocument.Parse(response.Content.ReadAsStringAsync().Result);
        }
    }
    // If the response has exactly one Attachment element, the upload has completed successfully
    XNamespace ns = "http://service.powerclerk.com/api/v1/";
    List<XElement> attachmentElements = xmlResponse.Descendants(ns + "Attachment").ToList();
    if (attachmentElements.Count != 1)
    {
        return false;
    }
    return true;
}

What’s Next?