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

GetProjectStatusHistory – Admin only

Get the status history associated with a given project. Returns a list of statuses entered by the project along with the timestamp of each status entry. If the project has entered a given status multiple times, one output line will be returned for each status entry (see example below).
 
Requires membership in an administrator role and read access to the program and project.
 
HTTP verb: GET
Required inputs: ProgramId, ProjectId

URL Format

Format: https://{BaseURL}/Programs/{ProgramId}/Projects/{ProjectId}/StatusHistory?version={VersionNumber}
 
Sample: https://{BaseURL}/Programs/A43FN6B/Projects/D4GJR65/StatusHistory?version=2

Version 2 Sample Response


<ProjectStatusHistoryResponse>
    <Project ProjectId="JC8SR659PV" ProgramId="1HF29X4P" ProjectNumber="TEST-00011">
        <StatusHistory>
            <Status StatusId="U2KE36T4" Name="Permission to Operate" ChangedBy="solar@cleanpower.com" Timestamp="2015-04-14T09:43:24-07:00"/>
            <Status StatusId="U11N9F91" Name="Application Review" ChangedBy="solar@cleanpower.com" Timestamp="2015-04-14T09:41:17-07:00"/>
            <Status StatusId="759NA6NH" Name="Inspection Pending" ChangedBy="solar@cleanpower.com" Timestamp="2015-04-14T09:39:40-07:00"/>
            <Status StatusId="U11N9F91" Name="Application Review" ChangedBy="solar@cleanpower.com" Timestamp="2015-04-08T11:10:29-07:00"/>
            <Status StatusId="3X8KK600" Name="Unsubmitted" ChangedBy="solar@cleanpower.com" Timestamp="2015-04-08T11:03:07-07:00"/>
        </StatusHistory>
    </Project>
</ProjectStatusHistoryResponse>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://services.powerclerk.com/api/v1/">
  <xs:element name="ProjectStatusHistoryResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Project">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="StatusHistory">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Status" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute type="xs:string" name="StatusId" 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="ChangedBy" use="required"/>
                            <xs:attribute type="xs:dateTime" name="Timestamp" use="required"/>
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute type="xs:string" name="ProjectId" use="required"/>
            <xs:attribute type="xs:string" name="ProgramId" use="required"/>
            <xs:attribute type="xs:string" name="ProjectNumber" use="optional"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute type="xs:float" name="SchemaVersion"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Response XML Attributes

<Project> Attributes

ProjectId – Unique identifier for the project
ProgramId – Unique identifier for the program
ProjectNumber – The project number. Projects are assigned a project number when they have been submitted.
 

<Status> Attributes

StatusId – Unique identifier for the status
CustomId – Custom, admin-provided, unique identifier for the status
Name – Status name
ChangedBy – Name of the user who initiated the status change
Timestamp – Timestamp of when the project entered the given status. Converted to user’s local timezone.

Version 1 Sample Response


<ProjectStatusHistoryResponse>
    <Project ProjectId="JC8SR659PV" ProgramId="1HF29X4P" ProjectNumber="TEST-00011">
        <StatusHistory>
            <Status StatusId="U2KE36T4" Name="Permission to Operate" Timestamp="2015-04-14T09:43:24-07:00"/>
            <Status StatusId="U11N9F91" Name="Application Review" Timestamp="2015-04-14T09:41:17-07:00"/>
            <Status StatusId="759NA6NH" Name="Inspection Pending" Timestamp="2015-04-14T09:39:40-07:00"/>
            <Status StatusId="U11N9F91" Name="Application Review" Timestamp="2015-04-08T11:10:29-07:00"/>
            <Status StatusId="3X8KK600" Name="Unsubmitted" Timestamp="2015-04-08T11:03:07-07:00"/>
        </StatusHistory>
    </Project>
</ProjectStatusHistoryResponse>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://services.powerclerk.com/api/v1/">
  <xs:element name="ProjectStatusHistoryResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Project">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="StatusHistory">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Status" maxOccurs="unbounded" minOccurs="0">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute type="xs:string" name="StatusId" use="required"/>
                            <xs:attribute type="xs:string" name="CustomId" use="optional"/>
                            <xs:attribute type="xs:string" name="Name" use="required"/>
                            <xs:attribute type="xs:dateTime" name="Timestamp" use="required"/>
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute type="xs:string" name="ProjectId" use="required"/>
            <xs:attribute type="xs:string" name="ProgramId" use="required"/>
            <xs:attribute type="xs:string" name="ProjectNumber" use="optional"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute type="xs:float" name="SchemaVersion"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Response XML Attributes

<Project> Attributes

ProjectId – Unique identifier for the project
ProgramId – Unique identifier for the program
ProjectNumber – The project number. Projects are assigned a project number when they have been submitted.
 

<Status> Attributes

StatusId – Unique identifier for the status
CustomId – Custom, admin-provided, unique identifier for the status
Name – Status name
Timestamp – Timestamp of when the project entered the given status. Converted to user’s local timezone.

Sample Code


// Retrieve the status history for the given project.
// Returns a list of <StatusId, StatusName, Timestamp> tuples, one for each status change.

public List<Tuple<string, string, string>> GetStatusHistory(string programId, string projectId, string username, string password, string apiKey)
{
    string url = "/Programs/" + programId + "/Projects/" + projectId + "/StatusHistory";
    XDocument xmlResponse = MakeGetRequest(BaseUrl + url, username, password, apiKey);

    XNamespace ns = "http://services.powerclerk.com/api/v1/";
    List<XElement> statusElements = xmlResponse.Descendants(ns + "Status").ToList();

    List<Tuple<string, string, string>> statusInfo = new List<Tuple<string, string, string>>();
    foreach (XElement element in statusElements)
    {
        string statusId = element.Attribute("StatusId").Value;
        string statusName = element.Attribute("Name").Value;
        string timestamp = element.Attribute("Timestamp").Value;
        statusInfo.Add(new Tuple<string, string, string>(statusId, statusName, timestamp));
    }
    return statusInfo;
}

function getStatusHistory(programId, projectId) {
    // Use $.ajax jQuery method to execute the API call
    $.ajax({
        type: "GET",
        url: "https://{BaseURL}/Programs/" + programId + "/Projects/" + projectId + "/StatusHistory",
        dataType: "xml",
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "Basic " + hashedCredentials);
            xhr.setRequestHeader("X-ApiKey", apiKey);
        },
        success: function (xml) {
            // Display data
        },
        error: function (xhr) {
            // Display error
        }
    });
}
See Chapter Code Samples for MakeGetRequest sample code.