<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to write a custom function getting Response from the API or URL. Whether it is Error or Succ in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4381749#M59188</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/396793"&gt;@KR300&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can create a custom function that calls each URL, checks the HTTP status, and returns a result record to identify whether the link is available or not&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;read this blog it will be helpful&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.tonymcgovern.com/blog/web-api-error-handling/" target="_blank"&gt;https://www.tonymcgovern.com/blog/web-api-error-handling/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(url as text) as record =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;response = Web.Contents(url, [ManualStatusHandling={404,400,500}]),&lt;BR /&gt;responseStatus = Value.Metadata(response)[Response.Status],&lt;BR /&gt;result =&lt;BR /&gt;if responseStatus = 200 then&lt;BR /&gt;[Status = 200, Message = "Link available"]&lt;BR /&gt;else if responseStatus = 404 then&lt;BR /&gt;[Status = 404, Message = "Link not available"]&lt;BR /&gt;else&lt;BR /&gt;[Status = responseStatus, Message = "Other error"]&lt;BR /&gt;in&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.Create a table of Versions and their corresponding hyperlinks.&lt;BR /&gt;2. Add a custom column that invokes the above function for each URL.&lt;BR /&gt;3. Expand the returned record to see the status code and the custom message.&lt;BR /&gt;4. If the status code is 200, you can treat the link as valid. If it is 404, you can display that the link is not yet published.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This discussion is helpful as well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.reddit.com/r/PowerBI/comments/mm0be7/handling_http_errors_in_webcontents_calls/" target="_blank"&gt;https://www.reddit.com/r/PowerBI/comments/mm0be7/handling_http_errors_in_webcontents_calls/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this resolves the query. If yes give kudos and accept the answer&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2025 06:18:43 GMT</pubDate>
    <dc:creator>nilendraFabric</dc:creator>
    <dc:date>2025-01-27T06:18:43Z</dc:date>
    <item>
      <title>How to write a custom function getting Response from the API or URL. Whether it is Error or Success.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4381740#M59187</link>
      <description>&lt;P&gt;Hi Team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Description:&amp;nbsp;&lt;/STRONG&gt;My team is publishing a document in the web for each Version( Internally how the Team is doing on the Product development).&lt;/P&gt;&lt;P&gt;Let's say Documents are available in the web ( i am creating dynamic links in the PBI desktop&amp;nbsp; SFP.R.1.1,&amp;nbsp;&amp;nbsp;SFP.R.1.2,&amp;nbsp;SFP.R.1.3 ) but not sure when these are published/will publish in web - No perfect date ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I need to write a custome function to check or get response from the API or HTTP request.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Can we save that response a table in Power BI&lt;/P&gt;&lt;P&gt;2. Based on the response&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;If the response is an &lt;STRONG&gt;error&lt;/STRONG&gt; or &lt;STRONG&gt;404 not found -- I need to show Link/URL is not available&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;If the response is a &lt;STRONG&gt;success&lt;/STRONG&gt; or &lt;STRONG&gt;200&lt;/STRONG&gt; &lt;STRONG&gt;-- I need to show Link/URL is available&amp;nbsp; &amp;nbsp; then The USER's/LEADERSHIP directly get to know that informayon whether the URL/Link is available or not, + They will ask the below one why it is not published/ not ready yet.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 06:07:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4381740#M59187</guid>
      <dc:creator>KR300</dc:creator>
      <dc:date>2025-01-27T06:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a custom function getting Response from the API or URL. Whether it is Error or Succ</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4381749#M59188</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/396793"&gt;@KR300&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can create a custom function that calls each URL, checks the HTTP status, and returns a result record to identify whether the link is available or not&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;read this blog it will be helpful&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.tonymcgovern.com/blog/web-api-error-handling/" target="_blank"&gt;https://www.tonymcgovern.com/blog/web-api-error-handling/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(url as text) as record =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;response = Web.Contents(url, [ManualStatusHandling={404,400,500}]),&lt;BR /&gt;responseStatus = Value.Metadata(response)[Response.Status],&lt;BR /&gt;result =&lt;BR /&gt;if responseStatus = 200 then&lt;BR /&gt;[Status = 200, Message = "Link available"]&lt;BR /&gt;else if responseStatus = 404 then&lt;BR /&gt;[Status = 404, Message = "Link not available"]&lt;BR /&gt;else&lt;BR /&gt;[Status = responseStatus, Message = "Other error"]&lt;BR /&gt;in&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.Create a table of Versions and their corresponding hyperlinks.&lt;BR /&gt;2. Add a custom column that invokes the above function for each URL.&lt;BR /&gt;3. Expand the returned record to see the status code and the custom message.&lt;BR /&gt;4. If the status code is 200, you can treat the link as valid. If it is 404, you can display that the link is not yet published.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This discussion is helpful as well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.reddit.com/r/PowerBI/comments/mm0be7/handling_http_errors_in_webcontents_calls/" target="_blank"&gt;https://www.reddit.com/r/PowerBI/comments/mm0be7/handling_http_errors_in_webcontents_calls/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this resolves the query. If yes give kudos and accept the answer&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 06:18:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4381749#M59188</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-01-27T06:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a custom function getting Response from the API or URL. Whether it is Error or Succ</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4383608#M59202</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp;, Thank you so much you info. Will test it &amp;amp; let you know..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be great if any .pbix file&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 07:08:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4383608#M59202</guid>
      <dc:creator>KR300</dc:creator>
      <dc:date>2025-01-28T07:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a custom function getting Response from the API or URL. Whether it is Error or Succ</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4386610#M59244</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp; Thanks for your info. I am getting responses&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Status: 404&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Message: Link not Available.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But i want this as a table in power Query so that i can convert likw below for the dynamic purpose&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Message&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;404&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Link not Available&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 16:19:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-write-a-custom-function-getting-Response-from-the-API-or/m-p/4386610#M59244</guid>
      <dc:creator>KR300</dc:creator>
      <dc:date>2025-01-29T16:19:36Z</dc:date>
    </item>
  </channel>
</rss>

