Application & Process Automation

Getting Started
Authentication & Access
Accounts with Multi-Factor Authentication
Agency and Program Information
Common Usage Scenarios
Create and Submit a Project
Add/Change Data in an Existing Project
Daily Polling for Project Changes
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
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
URL Format
Sample Response
Response XML Attributes
Sample Code
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
Code Samples
EncodeAuthorizationHeader
MakeGetRequest
MakePostRequest
MakeGetFileRequest
MakeDeleteRequest
PowerShell

GetPrograms

Retrieves a list of programs associated with the given agency that are read-accessible to the user.
 
HTTP verb: GET
Required inputs: AgencyId

URL Format

Format: https://{BaseURL}/Programs?Agency={AgencyId}
Sample: https://{BaseURL}/Programs?Agency=FN7635MW

Response


<ProgramsResponse>
 <Programs>
  <Program ProgramId="A43FN6BR" AgencyId="7JWS463" ProgramName="Residential Solar Interconnection Program" AgencyName="Figment Light and Power" />
  <Program ProgramId="1HF29X4P" AgencyId="7JWS463" ProgramName="Commercial Solar Interconnection Program" AgencyName="Figment Light and Power" />
 </Programs>
</ProgramsResponse>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://service.powerclerk.com/api/v1/">
  <xs:element name="ProgramsResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Programs">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Program" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute type="xs:string" name="ProgramId" use="required"/>
                        <xs:attribute type="xs:string" name="AgencyId" use="required"/>
                        <xs:attribute type="xs:string" name="ProgramName" use="required"/>
                        <xs:attribute type="xs:string" name="AgencyName" use="required"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      <xs:attribute type="xs:float" name="SchemaVersion"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

Response XML Attributes

ProgramId – Unique identifier for the program
AgencyId – Unique identifier for the agency
ProgramName – Program name
AgencyName – Agency name

Sample Code


// Retrieves info about all programs in a given agency.
// Returns a list of <ProgramId, ProgramName> pairs, one for each program in the list.

public List<Tuple<string, string>> GetProgramInfo(string agencyId, string username, string password, string apiKey)
{
    string url = "/Programs?Agency=" + agencyId;
    XDocument xmlResponse = MakeGetRequest(BaseUrl + url, username, password, apiKey);

    XNamespace ns = "http://service.powerclerk.com/api/v1/";
    List<XElement> programElements = xmlResponse.Descendants(ns + "Program").ToList();

    List<Tuple<string, string>> programs = new List<Tuple<string, string>>();
    foreach (XElement programElement in programElements)
    {
        string programId = programElement.Attribute("ProgramId").Value;
        string programName = programElement.Attribute("ProgramName").Value;
        programs.Add(new Tuple<string,string>(programId, programName));
    }
    return programs;
}


function getPrograms(agencyId) {
    // Use $.ajax jQuery method to execute the API call
    $.ajax({
        type: "GET",
        url: "https://{BaseURL}/Programs?Agency=" + agencyId,
        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.

What’s Next?