QueryByAttribute not working.
tnakazawa opened this issue · 4 comments
tnakazawa commented
Im using PHP Version 7.3.25
dynamics-webapi-toolkit Installed by composer.
This code return cURL error No.3.
Code
$settings = new \AlexaCRM\WebAPI\OData\OnlineSettings();
$settings->instanceURI = $this->instanceURI;
$settings->applicationID = $this->applicationID;
$settings->tenantID = $this->tenantID;
$settings->applicationSecret = $this->applicationSecret;
$settings->apiVersion = $this->apiVersion;
$settings->tlsVerifyPeers = false;
$middleware = new \AlexaCRM\WebAPI\OData\OnlineAuthMiddleware( $settings );
$odataClient = new \AlexaCRM\WebAPI\OData\Client( $settings, $middleware);
$client = new \AlexaCRM\WebAPI\Client( $odataClient );
$query = new \AlexaCRM\Xrm\Query\QueryByAttribute( 'contact' );
$query->ColumnSet = new \AlexaCRM\Xrm\ColumnSet( true );
$collection = $client->RetrieveMultiple( $query );
return $collection;
Error
Error: [AlexaCRM\WebAPI\ToolkitException] cURL error 3: <url> malformed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
Please tell me how to fix this problem.
georged commented
@tnakazawa as per https://github.com/AlexaCRM/dynamics-webapi-toolkit/#prerequisites: minimum supported PHP version is 7.4
tnakazawa commented
@georged thank you for your massage.
I upgrade PHP Version 7.4.13, but this problem is not fix. same error reporting.
georged commented
@tnakazawa please provide full sample code including composer.json file
the following code works in our tests.
<?php
require_once 'vendor/autoload.php';
$settings = new \AlexaCRM\WebAPI\OData\OnlineSettings();
$settings->instanceURI = 'https://yourinstance.crmX.dynamics.com';
$settings->applicationID = '<guid>';
$settings->applicationSecret = '<secret>';
$settings->tlsVerifyPeers = false;
$middleware = new \AlexaCRM\WebAPI\OData\OnlineAuthMiddleware( $settings );
$odataClient = new \AlexaCRM\WebAPI\OData\Client( $settings, $middleware);
$client = new \AlexaCRM\WebAPI\Client( $odataClient );
$query = new \AlexaCRM\Xrm\Query\QueryByAttribute( 'contact' );
$query->ColumnSet = new \AlexaCRM\Xrm\ColumnSet( [ 'fullname', 'emailaddress1' ] );
$collection = $client->RetrieveMultiple( $query );
foreach($collection as $c) {
echo "{$c['fullname']}, {$c['emailaddress1']}\r\n";
}
composer.json
{
"require": {
"php": "^7.4",
"alexacrm/dynamics-webapi-toolkit": "^2.6"
}
}