Hi Readers,
This is the end of the series about External integration using web services or API. Hope you learned something from the series and will be able to utilize this information to develop great solution.
As discussed in last article we will Test customization using API that we developed this week for integration from #msdyn365bc or #MSDynNAV.
If you want to see other articles in this series please refer here.
We will need to use same website to Test this process. This process will require a Base64 Value for testing.
To use API we will require URL to access the API Page. Let's understand that part.Business Central 2020 wave 2 support API V1 and V2. In our example we have specified V1 in our API Page. So let's first build URL to access custom API Page that we have developed.
URL is different based on environment -
** Parameters in Red Need to be replaced by actual values
For SaaS - https://api.businesscentral.dynamics.com/v1.0/<user domain name>/api/<API publisher>/<API group>/<API version>/companies(<company id>)/<entitySetName>
For Sandbox - https://api.businesscentral.dynamics.com/v1.0/<sandboxtenantid>/sandbox/api/<API publisher>/<API group>/<API version>/companies(<company id>)/<entitySetName>
For Docker - (Use https if you are using a certificate) -
http://<containername>:<port>/<servicename>/api/<API publisher>/<API group>/<API version>/companies(<company id>)/<entitySetName>
For On-prem - (Use https if you are using a certificate) -
http://<servername>:<port>/<servicename>/api/<API publisher>/<API group>/<API version>/companies(<company id>)/<entitySetName>
For our scenario (using docker container) let's set these values -
- Container Name - bc171ussandbox
- port - 7048
- service name - bc
- API Publisher - sauravdhyani
- API Group - demo
- API Version - v1.0
- Company id -
- EntitySetName - apiattachments
Now last parameter that we are missing is Company id. In Business Central starting Business Central 2020 wave 2, Each record have a unique GUID using SystemID field in each table.
As there can be multiple companies in database you need to provide detail of company in which you would like to perform action. You can get company ID by doing a get in Postman or manually from the client.
Call the Get using postman with URL and copy the company ID in which you would like to use - http://<containername>:<port>/<servicename>/api/<API publisher>/<API group>/<API version>/companies
Once you have company ID, your URL is complete like mine -
http://bc171ussandbox:7048/bc/API/v2.0/companies(264f8dd2-4a2a-eb11-bb4f-000d3a25f2a9)/attachments
So let's start testing.
Let's do a get to check can we access existing records in database. We will use Get, Input API URL, Specify Authentication & select Send to get existing records in the database.
We will receive all required values in the database.
Now let's follow same steps as we did in last article to get Base64 value using Bit64 Guru website and copy the Base64 value.
Using this Base 64, lets Post a record using API (via Postman).
Choose Post, Specify API URL, Select Body, Raw & JSon to add values of new record that we like to insert and then click Send.
Now final test with Base64 out value, lets do a get again and copy the Out64bit value.
And using Base64Guru, lets decode the value to see the actual object.
Let me know your views as comment to this article.
If you would like to use Media instead of blob in same example, please add that to comment and I will update source code.
If you would like to access the source code please refer GitHub.
Stay Tuned. Let me know your views as comment to this article.
Regards,
Saurav Dhyani
Saurav Dhyani
Comments
Post a Comment