Connect with us and enhance your M-Files experience using Unitfly Toolkit for M-Files. Here’s how to get started.
Configuration HTTP Integration
We would like to use the mentioned module to obtain the monthly average exchange rates and write them into an object type.
We have a value list with all currencies, and we need to include the currency and the year in a URL call, and then write the exchange rate back into M-Files.
Here is the data source: https://www.backend-rates.bazg.admin.ch/api/xmlavgyear/164?j=2024&activeSearchType=avg
We look forward to your feedback.
Best regards
Steve
this can be accomplished in HTTP integration with the usage of Dynamic URL body parameters and dynamic expression in the URL string. You can find the full configuration in the attachment I will just go through some notable configuration key values.
Here we define that the value used in the URL after the "/" will be the value of Property "Country" which holds a number representation of the country. In the case that you have sent 164 corresponds to Algeria.
"URL": "https://www.backend-rates.bazg.admin.ch/api/xmlavgyear/%PROPERTY_{PD.Country}%",
Because additional parameters are set as query parameters (after the '?' in the URL) we need to define them. In the case of j= we set this value to year value from property "Year". The second parameter we set as a static value is in the URL you have sent.
"QueryParameters": [ { "DynamicParameterType": "Expression", "Name": "j", "DynamicValue": "%PROPERTY_{PD.Year}%" }, { "Name": "activeSearchType", "DynamicParameterType": "Expression", "DynamicValue": "avg" } ],
Finally, we define XML transformation with XPath expression to extract the value of "avgRate" from the response. Here we define the value which will be returned as a Number value with culture en-US (meaning that the dot is a decimal separator). XPath transformation makes sure that we fetch the average rate of the first month that is in response. You can also save the array of average rates for multiple months.
"SetProperties": [ { "ResultKind": "Number", "ResultCardinality": "Single", "ResultType": "SimpleValue", "Property": "PD.Rate", "ResponseTransformation": "XPath", "XPath": "//*[local-name()='avgRate']", "ResultCulture": "en-US" } ]
Kind regards!
So, you came to the end of the page. This means you are passionate about technology as we are.
WATCH THE WEBINAR