coolrunner-dk / business-central-php Goto Github PK
View Code? Open in Web Editor NEWSDK for Microsoft Business Central
License: MIT License
SDK for Microsoft Business Central
License: MIT License
What is the structure of code to create an entry ? have you got a example ?
Hey, first of all thanks for the great work done here!
I have a quick question, does it also work with On-premise deployments?
Hi.
I finally got to testing the SDK on on-premise test environment.
I was able to get connection working after modifying SDK.php file line 80 from
'base_uri' => "https://api.businesscentral.dynamics.com/v2.0/$this->tenant/$this->environment/ODataV4/",
to
'base_uri' => "$this->tenant/ODataV4/",
and passing on-prem service url while starting instance and removing cloud prefix alltogether.
But I'm having issues building models and populating entities.md and was hoping you could help me out a bit.
First I tried post-autoload-dump script. I failed passing credentials from composer.json. Composer simply did not validate json. Then I tried defining default variable values at Constructor.php buildModels function. Then the script ran but ended up with error:
Script BusinessCentral\Constructor::buildModels handling the post-autoload-dump event terminated with an exception [ErrorException] Object of class Composer\Script\Event could not be converted to string
Finnaly tried building models directly from php script by calling
BusinessCentral\Constructor::buildModels( 'server:port/instance', 'username', 'password' );
And got buntch of undefined index errors and failing:
Undefined index: NAV in C:\wamp64\www\ekodumaja\vendor\coolrunner\business-central-sdk\src\Schema.php on line 59 Undefined index: @attributes in C:\wamp64\www\ekodumaja\vendor\coolrunner\business-central-sdk\src\Schema.php on line 40 Undefined index: Namespace in C:\wamp64\www\ekodumaja\vendor\coolrunner\business-central-sdk\src\Schema.php on line 40 Undefined index: NAV.ComplexTypes in C:\wamp64\www\ekodumaja\vendor\coolrunner\business-central-sdk\src\Schema.php on line 55 Invalid argument supplied for foreach() in C:\wamp64\www\ekodumaja\vendor\coolrunner\business-central-sdk\src\Schema.php on line 55
Am I missing something obvious here?
Maybe you can provide me sample of your working composer.json in case i'm not including something important there.
If I get some time I will make a fork and make pull request regarding on-premise tenant URL fix.
I noticed that when instantiating a Model/Entity it does a call to the API , this is triggered from
EntityCollection::__construct.
When setting the limit high, this fetches a lot of data.
I had a look, but the propagate is really dependent in the construct functionality.
I also thought about limiting the construct to 1, but believe this has consequences for the pagination?
Hi
I'm sorry for asking this here as I'm sure this is a problem with my Business Central set-up and not with this project. I don't know much about Business Central but I've followed some instructions on the web and got Azure AD OAuth configured and working with a trial Business Central set-up in the cloud. I've done some searching but I've not been able to find a solution to my problem.
The SDK appeared to work fine for the fist request but subsequent requests have generated this error:
Server error: `GET https://api.businesscentral.dynamics.com/v2.0/afcd4d86-327b-4160-baad-c45589c7eddb/production/ODataV4/$metadata` resulted in a `500 Internal Server Error` response:
{"error":{"code":"Unknown","message":"An item with the same key has already been added. CorrelationId: 40da9e46-37e9-4 (truncated...)
Using the same request in Postman generates the same result.
{
"error": {
"code": "Unknown",
"message": "An item with the same key has already been added. CorrelationId: d04c747b-44b2-41cc-82b2-57db29f88414."
}
}
Do you know what I need to do in Business Central to fix this?
i am getting this error, i am unable to fix this ,
When we create an item ( workflowItems ), we set the 'type' attribute, but this conflicts with the class property and magic methods.
The workaround was not using the fill method from the EntityCollection, but directly use "Entity::make".
When creating a SalesDocument I wanted to directly do a deep insert ( add SalesDocumentLines in the same call ), but noticed the library doesn't yet support this, are there any plans for this?
Hi Morten.
Thanks for your work!!
Is it possible to update the guzzle requirements, so it is possible to require it with Laravel 8?
Thanks!
Hi,
I'm getting the error Call to a member function getEntityType() on null
when I try to do any query.
It seems the problem starts in `EntityCollection.ph , line 77:
$this->type = $this->query->getEntitySet($response['@odata.context']);
$response['@odata.context']
has a valid content:
https://api.businesscentral.dynamics.com/v2.0/myTenant/sandbox/ODataV4/$metadata#Company
$response
looks good as well (array of value is there; 1 element in it, with Name, Display_Name, Id, ...
But $this->query->getEntitySet
returns null
Complete usage of SDK:
$sdk = \BusinessCentral\SDK::instance($myTenant, [
// OAuth2 [Required]
'client_id' => $myClientId,
// Basic auth token [Required]
'client_secret' => $mySecret,
// Default collection size [Optional]
// Amount of entities to load initially and per page per collection
// Can be changed on the fly on any collection instance
'default_collection_size' => 20,
// Default environment [Optional - 'production' by default]
'environment' => 'sandbox',
]);
$company = $sdk->company('company');
At creating the instance some warnings will come - maybe this is the reason?
Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "Namespace" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "Namespace" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40
Warning: Undefined array key "NAV.ComplexTypes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55
Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55
Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59
Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59
Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63
Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63
Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67
Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67
Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67
PHP Version: 8.1.6
Hi.
Im trying to connect to my BC Environment and im getting an ErrorException
Undefined array key "@attributes" on line 'client_id' => .....
` public function test(){
$sdk = SDK::instance('######', [
// OAuth2 [Required]
'client_id' => '######',
// Basic auth token [Required]
'client_secret' => '######',
// Default collection size [Optional]
// Amount of entities to load initially and per page per collection
// Can be changed on the fly on any collection instance
'default_collection_size' => 20,
// Default environment [Optional - 'production' by default]
'environment' => 'TESTES'
]);
}`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.