How to generate a Portrait Dialogue report on the server using the API and return XML containing the report in a specified format

The 'GenerateReport' operation is accessible from 'DialogServerAPI'.
To find it, open Internet Information Services (IIS) Manager, locate 'MHDialogServerAPI' web application:
User-added image
and hit 'Browse' on the right side panel:
User-added image
Million Handshakes Dialog Server API will open:
User-added image
If Report API is clicked, the list of ReportAPIService entries are shown:
User-added image
The GenerateReport operation has a number of parameters that need to be supplied before the 'Invoke' button can be hit.

User-added image
The following explains how to supply the parameters:

To get the ServerSession value use the following formula:
ServerSession = SessionKey + "@" + InstanceName
The ServerSession value takes the following form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@InstanceName
Before ServerSession can be supplied the SessionKey needs to be generated in another operation in Million Handshakes Dialog Server API and 'InstanceName' can be found from Dialog Admin.
SessionKey can be found from:
User-added image

then 'Login':
User-added image
As above, Login takes a number of parameters as shown below.
 User-added image

Clicking the 'Invoke' button results in the following output:
User-added image
The above example shows the generated session key as "8A533343-EC7C-4C7A-9E85-7C9F8A3978C0".
Now we are ready to construct the ServerSession value which would now look like this: 
It can now be used in the 'GenerateReport' operation.

User-added image
The ReportTemplateID is the is the unique ID of the report template and can be found in the URL string when a desired report is opened in the Report Portal.

User-added image
The Params value is an XML document containing a set of parameters used when generating the report. Some report templates will require a set of parameters to be specified, others will not.

Email Template ID</name>


The FormatIndex value should be set as follows:
User-added image
User-added image

User-added image
The IncludeBinaryOutput boolean value specifies if the binary representation of the generated report should be included in the returned XML document. 

User-added image

In some situations, the following exception message appears after hitting Invoke button:
System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (Params=&quot;&lt;?xml version=&quot;1.0&quot;?...&quot;).
   at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
   at System.Web.HttpRequest.ValidateHttpValueCollection(HttpValueCollection collection, RequestValidationSource requestCollection)
   at System.Web.HttpRequest.get_Form()
   at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
   at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

To resolve this, alter the validation mode in the C:\Program Files (x86)\PST\Million Handshakes Web\MHDialogServerAPI\web.config file.
The following line must be changed from:
    <httpRuntime maxRequestLength="16384" executionTimeout="180"/>
    <httpRuntime maxRequestLength="16384" executionTimeout="180" requestValidationMode="2.0"/>

UPDATED:  April 12, 2017