Skip to main content

#msdyn365bc - Test Base64 Conversion via API?

Hi Readers,

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 -<user domain name>/api/<API publisher>/<API group>/<API version>/companies(<company id>)/<entitySetName>

For Sandbox -<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
Other than first three parameters (which provide details of tenant) other parameters are based on what you set in your API Page.

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 - 

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.

Let's open business central to check records. And we will see new record inserted.

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.

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.

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.

Saurav Dhyani


Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.

NAV 2013 Upgrade Part III - Data Upgrading.

Hi all, As per agenda we need to discuss the data upgrade in NAV 2013. The process is similar to what used to be till NAV 2009 R2 but with some changes. Let's start the process. Remember -  1) You can only upgrade a database to NAV 2013 from NAV 2009 SP1 / R2 SQL Only. 2) The Synchronization of users with SQL Server is no more required.