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

Welcome - Microsoft Dynamics 365!

Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

NAV 2013 Credential Type - How to Use?

Hi all, Please do these activities when you have time, its a long activity and i would suggest do all activities in one go. So be clam and lets start. For NAV 2013 R2 Refer Here. For NAV 2016 Steps have been Reduced Please Refer Here. I have installed NAV 2013 and its work great with my windows credentials. I was checking the service console (Microsoft Dynamics NAV Administration) in NAV 2013 and found out that Credentials Type have multiple Options.