Working with RSS feeds might feel old-school, but they remain a reliable tool for aggregating and distributing content. Recently, I encountered an issue while experimenting with RSS feeds in an Azure Logic App, and I hope this quick post saves you the troubleshooting time I went through!
The goal was straightforward: check an RSS feed every couple of hours and post updates to a Teams channel. Simple, right? Turns out, there was a hitch in how Azure Logic Apps handles feed URLs. Let me walk you through the issue and its solution.
The Problem
When using the graphical editor in the Azure Portal to set up an RSS feed trigger, I ran into an issue where the feed URL was double-encoded. For my testing, I used the RSS feed from the BWC Blog’s development site:
https://dev-blog.builtwithcaffeine.cloud/rss.xml
From the Azure Portal this is what the workflow looks like out of the box when I first created it.
The source code for the workflow is this:
Notice, how the feedUrl is configured!
|
|
So we have the basics completed, Lets run the workflow and see the output of the rss feed.
Oh no! we have errors?! When we drill into the run history and look at the output response we this:
|
|
Notice! Notice how the message the urls has been encoded using html hexadecimal values. Not ok for an RSS Url! So having spent most of my evening trying different urls feeds and http and https, I was stumped, So I turned to the All Knowing AI. and after 40 minutes of throwing error codes and the JSON code at it, We cracked the issue!
The Solution
The TLDR method would be, check the ChatGPT prompt/conversation I had: https://chatgpt.com/share/6792b10e-5408-800f-b8f2-7760e2cf725c
For those who wish to save they’re mouse a click, this was the final response with the fix.
If the feedUrl
keeps being encoded automatically despite being correctly configured in the Logic App definition, it could be due to how the Logic App engine processes or stores the URL. Here’s how you can address this issue:
Steps to Fix
Check Logic App Inputs and Outputs
- Run the Logic App and inspect the inputs/outputs for the
ListFeedItems
action using the Run History in the Azure Portal. - Confirm whether the
feedUrl
is already encoded before being passed to the connector.
Force Decoding the URL
- If the encoding is happening upstream, ensure that no encoding logic is applied to the URL in earlier steps or variables.
Wrap the URL in an Expression
- Explicitly decode the URL using an inline expression in the Logic App definition. Replace:
|
|
- With
|
|
Ensure Proper Encoding Handling in the Logic App Designer
If you’re editing the Logic App via the Azure Portal, confirm that the URL isn’t being automatically encoded when saved.
Sometimes, using the designer can introduce unexpected transformations. Use the Code View to ensure your definition is accurate.
Why @decodeUriComponent Helps
When working with URLs in Azure Logic Apps, encoding issues can often cause unexpected behaviors, especially when dealing with special characters or non-ASCII symbols. These encoding issues typically occur when a URL is passed through various systems or functions that might unintentionally modify or double-encode certain characters. The @decodeUriComponent
function explicitly decodes the URL, ensuring that any previously encoded characters (such as %20
for spaces or %3A
for colons) are correctly restored to their original form.
For example, if an RSS feed URL is passed through a connector or a trigger, it might include characters like spaces, ampersands, or question marks, which can be encoded as %20
, %26
, or %3F
, respectively. Without decoding these components, the RSS connector might fail to parse the URL correctly, causing issues in fetching or processing the feed.
By applying @decodeUriComponent
, you are effectively neutralizing any unnecessary encoding that could be causing the Logic App to fail. This ensures that the RSS connector receives the URL in the exact format it expects, reducing the chance of errors and improving reliability.
Updated Logic App Code
|
|
Testing the Logic!
If we look at the successful run and check the rss outputs we now see
Wrap Up
RSS feeds are still a valuable tool for automating content aggregation, but issues like URL encoding can throw a wrench in your Logic App workflows. In this post, we walked through a common challengeādouble-encoded RSS feed URLsāand how to fix it.
By using the @decodeUriComponent function in your Logic App, you can ensure that the URL is decoded correctly, preventing errors in the RSS connector and ensuring smooth data retrieval. Editing the Logic App in Code View rather than the designer can help avoid unexpected transformations.
If issues persist, consider reaching out to Azure Support, as the problem could be a bug. With this fix, you should be able to get your Logic App up and running with reliable RSS feed automation. Happy coding!