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,
i8sy72 opened this issue · 5 comments
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.
@i8sy72 that looks like a message coming down the wire from Dataverse, i.e. from a plugin.
- Can you create a contact using model-driven app at https://mydynamicsdomain.crm6.dynamics.com/?
- Try creating something else like account record?
@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
checking the field names in XRMToolBox the name is lastname not LastName but I have checked that both ways too
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.
I do have a custom plugin added to the solutions but I dont have any custom code for contact
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