php-ews
php-ews copied to clipboard
Restriction SearchExpression validation
Hello.
I'm trying to use this package to search some contacts by their email address. This is not working.
The error I get is:
The request failed schema validation: The element 'Restriction' in namespace 'http://schemas.microsoft.com/exchange/services/2006/messages' has incomplete content. List of possible elements expected: 'SearchExpression' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.
And this is my code:
$api = API::withUsernameAndPassword($host, $user, $pass);
$folder = $api->getFolderByDisplayName('FolderName', Enumeration\DistinguishedFolderIdNameType::CONTACTS);
$request = [
'ItemShape' => [
'BaseShape' => 'AllProperties',
],
'Traversal' => 'Shallow',
'ParentFolderIds' => [
'FolderId' => $folder->getFolderId()->toXmlObject()
],
'Restriction' => [
[
'Contains' => [
'ContainmentMode' => 'FullString',
'ContainmentComparison' => 'IgnoreCase',
'FieldURI' => [
'FieldURI' => 'contacts:EmailAddresses'
],
'Constant' => [
'Value' => '[email protected]'
],
],
],
],
];
$request = Type::buildFromArray($request);
$items = $api->getClient()->FindItem($request);
I can't get it to work and I've checked some of the issues and code examples without any success. Am I doing anything wrong?
I have the same problem:
array(
'FieldURI' => array(
'FieldURI' => 'item:Subject'
),
'Constant' => array(
'Value' => 'XYZ'
),
'ContainmentMode' => \garethp\ews\API\Enumeration\ContainmentModeType::SUBSTRING,
'ContainmentComparison' => \garethp\ews\API\Enumeration\ContainmentComparisonType::IGNORE_CASE
)
Resulting XML:
<ns1:Contains>
<ns1:FieldURI FieldURI=""/>
<ns1:Constant/>
</ns1:Contains>
So there are some fields missings in request. The problem might be that containments are attributes in main tag of expression and no separate tags beyond.
PS: Is that possible with current implementation because I don't see possibility to add atrributes?