/* An Example XML Request */
string xmlRequest = '
<request>
<auth>
<type>basic</type>
</auth>
<requestId>15</requestId>
<method>
<name>sendLeaseDocuments</name>
<params>
<propertyId>xxx</propertyId> <!-- required -->
<leaseId>xxxx</leaseId> <!-- Required -->
<files>
<file>
<fileName>file1.pdf</fileName> <!-- required -->
<leaseFileType>OTHER</leaseFileType>
<!-- required. Use the system code of the leaseFileType node from the getPickLists API response. -->
<isShowInResidentPortal>1</isShowInResidentPortal>
<customerIds>xxx,xxx</customerIds>
<!-- optional, if provided this file will attach to the mentioned customers. if skipped, this file will attached to all the customers -->
</file>
<file>
<fileName>file2.pdf</fileName> <!-- required -->
<leaseFileType>OTHER</leaseFileType>
<!-- required. Use the system code of the leaseFileType node from the getPickLists API response. -->
<isShowInResidentPortal>1</isShowInResidentPortal>
<customerIds>xxx,xxx</customerIds>
<!-- optional, if provided this file will attach to the mentioned customers. if skipped, this file will attached to all the customers -->
</file>
</files>
</params>
</method>
</request>' ;
/* An Example JSON Request */
$jsonRequest = '{
"auth": {
"type": "basic"
},
"requestId": "15",
"method": {
"name": "sendLeaseDocuments",
"params": {
"propertyId": "xxx",
"leaseId": "xxxx",
"files": {
"file": [
{
"fileName": "file1.pdf",
"leaseFileType": "OTHER",
"isShowInResidentPortal": "1",
"customerIds": "xxx,xxx"
},
{
"fileName": "file2.pdf",
"leaseFileType": "OTHER",
"isShowInResidentPortal": "1",
"customerIds": "xxx,xxx"
}
]
}
}
}
}' ;
$resCurl = curl_init();
curl_setopt( $resCurl, CURLOPT_POST, true );
curl_setopt( $resCurl, CURLOPT_URL, REPLACE THIS WITH THE WEB SERVICE URL );
curl_setopt( $resCurl, CURLOPT_RETURNTRANSFER, 1 );
$strFirstFileName = '<filename with path>';
$strSecondFileName = '<filename with path>';
if( true == function_exists( 'curl_file_create' ) ) {
$strFirsFilePath = curl_file_create( $strFirstFileName );
$strSecondFilePath = curl_file_create( $strSecondFileName );
} else {
$strFirsFilePath = '@' . realpath( $strFirstFileName );
$strSecondFilePath = '@' . realpath( $strSecondFileName );
}
/* If you want to send an XML Request, use these options */
$arrmixPost = [ 'requestContentType' => 'APPLICATION/XML; CHARSET=UTF-8', 'requestBody' => $xmlRequest, 'file1' => $strFirsFilePath, 'file2' => $strSecondFilePath ];
/* If you want to send a JSON Request, use these options */
$arrmixPost = [ 'requestContentType' => 'APPLICATION/JSON; CHARSET=UTF-8', 'requestBody' => $jsonRequest, 'file1' => $strFirsFilePath, 'file2' => $strSecondFilePath ];
curl_setopt( $resCurl, CURLOPT_HTTPHEADER, array( 'Content-type: multipart/form-data', 'Authorization: Basic <BASE64 ENCODED VALUE OF USERNAME:PASSWORD>' ) );
curl_setopt( $resCurl, CURLOPT_POSTFIELDS, $arrmixPost );
$result = curl_exec( $resCurl );
if( false === $result ) {
echo 'Curl error: ' . curl_error( $resCurl );
curl_close( $resCurl );
} else {
curl_close( $resCurl );
echo $result;
}