Skip to main content

Posts

Showing posts with the label WebServices

Recurring import General Journal file using Microsoft Flow #MicrosoftFlow #MSDyn365FO

Microsoft Flow is a simple and cost effective way of integrating. In this post I will walk through how to use Flow for recurring file integration. The most common scenario I can think of is the general journal import. First, I would recommend reading Microsoft article on recurring integration. https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/recurring-integrations Solution below shows you how to use Microsoft Flow to read from OneDrive for Business and import to FinOps. The exact same thing can be done using Logic Apps for a more enterprise managed solution. Lets start by setting up our folder structure to drop our general journal files in. Create four folders like so: inbound – drop the files here to be processed processing – Flow will move the file here from the inbound folder while executing success – Flow will move it here when the file has successfully been imported and processed error – Flow will move it here if the file fails to process...

Automated testing #MSDyn365FO Odata with Postman

In the last post I did a quick run through on using Postman for testing Odata services. This post I will give some tips on how you can write automated tests using Postman. Tip 1 – Parameterise as much as you can Parameterise using the environment settings. It will make your collection portable to other projects. Below is an example where we have the environments settings parameterised. You can see how I used it here. Now I can utilise the same thing across requests. Tip 2 – Write test scripts Test scripts are very easy to work with. This is for demonstration purpose only. I will explain how you can retrieve the values in the returned json. Take the example here, where we use the “get customer” odata service. It returns a nested array with the values. You can write a simple test script to retrieve values. In the below highlighted box you can see that I am logging it to the console. I am not really testing much here. The console will return the below.  One bonus tip here. Just click ...

Testing #MSDyn365FO Odata with Postman

Last year I posted on using Postman. Things have changed since then and I need to update. http://dynamicsnavax.blogspot.com/2017/05/dynamics-365-for-operation-web-service.html There is a good article that Microsoft has written which I followed without any issues. https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/third-party-service-test#prerequisites Below are some screenshot incase you are a visual person like me. In the environment set ups. It should looks something like this. When you run it, you should get a response. Once you got the token. You are good to go with your messages. Below is the same example from the blog post. You run into any problems, click on the console icon at the bottom. Should give you a bit more information. If you get a 401 error. It is usually a typo. Make sure you got the spaces and backslashes correct. One simple character can drive you crazy.

Azure AD Authentication for Windows Applications

In this post I will describe how you can get the login dialog to pop up when you are developing a windows desktop application. Below is an example of the dialog appearing. Below is a sample code how to acquire the token. string authorityUri = "https://login.windows.net/common/oauth2/authorize"; Uri redirectURI = new Uri("https://login.live.com/oauth20_desktop.srf"); AuthenticationContext authenticationContext = new AuthenticationContext(authorityUri); AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync( ClientConfig.Default.ActiveDirectoryResource, ClientConfig.Default.ActiveDirectoryClientAppId, redirectURI, new PlatformParameters(PromptBehavior.RefreshSession)).Result; Add the redirect URI for https://login.live.com/oauth20_desktop.srf Reference: https://docs.microsoft.com/en-us/rest/api/datacatalog/authenticate-a-client-app

Web Api App for AX 2012 to Azure–Intro

Last year I did a plug for a colleague who had developed this super nice solution which you can use to expose your AIF SOAP services as RESTful services. http://dynamicsnavax.blogspot.com.au/2016/04/expose-ax-2012-aif-services-soap-as.html Fabio has done a great job in sharing a great piece of work and also documenting it really well. What is missing is to take it to the next level. So, in a series of posts, I will show how to deploy this to Azure via Azure Api App and communicate with your on premise AOS. There are many benefits to this solution in the cloud Integration with Azure Logic Apps – this uses swagger and Logic Apps will work really nicely Expose for 3rd parties to securely integrate with your AX solution No need setting up complicated IIS/Firewalls/DMZ servers etc. Use Azure Authentication without a need to build anything Scale easily with the cloud Allows you to build mobile apps

Dynamics 365 for Operation Web Service calls with POSTMAN

UPDATE: 28 June 2018 - Follow this post for using secret key rather than asking user to log in http://dynamicsnavax.blogspot.com/2018/06/testing-msdyn365fo-odata-with-postman.html In this post I will explain using POSTMAN but it really doesn’t matter what tool you use (SOAPUI is another common tool). The main point I am trying to make is how to put the authentication piece together so you can start messaging to/from the web service. Download POSTMAN from their site https://www.getpostman.com/ In Azure AD register the application. For more info see previous post I wrote http://dynamicsnavax.blogspot.com.au/2016/09/azure-ad-in-new-portal.html For POSTMAN, you need to enter the redirect. POSTMAN would tell you this later when you try to get a token. Redirect URL: https://www.getpostman.com/oauth2/callback Open up POSTMAN and enter your URL you want to send a request to. Click on the bright orange button “Get New Access Token” This dialog will pop up. It will ask f...

Expose AX 2012 AIF services (SOAP) as RESTful web services

A colleague of mine Fabio Filardi has published his work on Github. It has two samples for the Expense services and UserSession services. He has documented it really well. Get onto it if you are going to expose your web services as RESTful. It does save you a lot of time. Github project https://github.com/ffilardi/AxaptaAPI Documentation under wiki https://github.com/ffilardi/axaptaapi/wiki   Here are some additional notes. Microsoft has documented it really well too. So, get your head around the concepts and the above links should be of great benefit to you. This is a good summary of the Azure service bus adapter with AX. http://blogs.msdn.com/b/aif/archive/2013/04/29/aif-windows-azure-service-bus-adapter.aspx Whitepaper from Microsoft on how to extend it. Microsoft provides an example by talking about mobile app. Concept is how to expose your web services securely outside the domain. https://www.microsoft.com/en-us/download/details.aspx?id=38413 Fabio has written a blog...

Online (Bing) translator for AX using a shortcut key

Keeping in theme with the last post, I will talk about another simple use for web services in AX. I will use Microsoft (Bing) Translator to automatically translate fields with just a shortcut key (in this example I will take over the Ctrl+Z shortcut). In \Classes\SysSetupFormRun add a new method. Copy and paste below. Make sure to replace the API ID with your own. Sign up to Microsoft API . Public static server void translate(str _text = "") { //ar,bg,zh-CHS,zh-CHT,cs,da,nl,en,et,fi,fr,de,el,ht,he,hu,id,it,ja,ko,lv,lt,no,pl,pt,ro,ru,sk,sl,es,sv,th,tr,uk,vi //Arabic Bulgarian Chinese Simplified Chinese Traditional Czech Danish Dutch English Estonian Finnish French //German Greek Haitian Creole Hebrew Hungarian Indonesian Italian Japanese Korean Latvian Lithuanian //Norwegian Polish Portuguese Romanian Russian Slovak Slovenian Spanish Swedish Thai Turkish Ukrainian Vietnamese str uri; str appId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Replace with your A...

Update exchange rate using Yahoo Web Service

In this example I am using Yahoo's online currency converter to update the exchange rates table. An idea would be to put this code in a batch class, which you can schedule to run daily. static void YahooCurrencyUpdate(Args _args) { Currency currency; ExchRates exchRates; str uri; str exchRate = ""; str fromCurrency, toCurrency; System.Net.HttpWebRequest httpRequest = null; System.Net.HttpWebResponse httpResponse = null; CLRObject clro = null; System.IO.Stream stream = null; System.IO.StreamReader streamReader = null; ; while select currency { fromCurrency = CompanyInfo::find().CurrencyCode; toCurrency = currency.CurrencyCode; uri = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=l1&s=" + fromCurrency + toCur...

NAV - Web portal through Web Services

I have been working on an idea for a while now. Using web services which had come in in NAV2009 - I wanted to create a simple web portal which would allow customers to login, view their sales orders, view their invoices, view/download their statement and update their own records. With out spending too much time on this. I downloaded a free stylesheet (css). Using basic .NET membership I was able to create those things. With going into too much detail. Here are some screenshots. I found this link useful to upskill on .NET membership controls etc. Microsoft - Membership and Login Controls There is a lot of info on the web. Just google/bing ".NET membership". Here is some code to list orders for a particular customer. using System; using System.Data; using System.Collections.Generic; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebContro...