AlexaCRM / dynamics-webapi-toolkit

Dynamics 365 Web API Toolkit for PHP
MIT License
75 stars 58 forks source link

Create request failed: Client error: `POST ... resulted in a `400 Bad Request` response with the following message: `Could not load file or assembly 'MySql.Data, Version=8.0.31.0, #90

Closed i8sy72 closed 1 year ago

i8sy72 commented 1 year ago

I am having problems when I do a $client->Create() call. I have been able to successfully complete a $client->Retrieve as well as a $client->RetrieveMultiple but when I attempt a $client->Create() with

$settings = new \AlexaCRM\WebAPI\OData\OnlineSettings();
$settings->instanceURI = 'https://mydynamicsdomain.crm6.dynamics.com';
$settings->applicationID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$settings->applicationSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$settings->apiVersion = '9.1';
$settings->tlsVerifyPeers = false; // I have tried with and without this

$middleware = new \AlexaCRM\WebAPI\OData\OnlineAuthMiddleware( $settings );
$odataClient = new \AlexaCRM\WebAPI\OData\Client( $settings, $middleware );
$client = new \AlexaCRM\WebAPI\Client( $odataClient );

$contact = new \AlexaCRM\Xrm\Entity( 'contact' );
$contact['firstname'] = 'Nancy';
$contact['lastname'] = 'Anderson';
$contact['emailaddress1'] = 'someonec@example.com';

$contactId = $client->Create( $contact );

I get this error: AlexaCRM\WebAPI\OrganizationException Create request failed: Client error: 'POST https://mydynamicsdomain.crm6.dynamics.com/api/data/v9.1/contacts' resulted in a '400 Bad Request' response with the following message: 'Could not load file or assembly 'MySql.Data, Version=8.0.31.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.'

Any help with this would be greatly appreciated.

georged commented 1 year ago

@i8sy72 that looks like a message coming down the wire from Dataverse, i.e. from a plugin.

i8sy72 commented 1 year ago

@georged thanks for the reply

I can create a contact at the dynamics site without issue.

I have also successfully created an account record with

    $account = new \AlexaCRM\Xrm\Entity( 'account' );
    $account['name'] = 'testAccount';

    $accountId = $client->Create( $account );

I also retried contact again with the minimum fields requirements

$contact = new \AlexaCRM\Xrm\Entity( 'contact' );
$contact['lastname'] = 'Anderson';

$contactId = $client->Create( $contact );

but still get the same error I have checked the required fields in the contact table and they are image

checking the field names in XRMToolBox the name is lastname not LastName but I have checked that both ways too

georged commented 1 year ago

The error is .NET style and is coming from a Dataverse plugin. You need to check what custom plugins are registered on the contact table.

i8sy72 commented 1 year ago

I do have a custom plugin added to the solutions but I dont have any custom code for contact

georged commented 1 year ago

@i8sy72

error is .NET and 99.99999% coming from Dataverse. If you're doubting that, take the toolkit out of the equation and try reproducing it using Web API either directly from Postman or from .NET.

You can also enable debug level logging for the toolkit and capture what's being sent/received.

HTH