Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection Learn more
You are tasked with fetching incident data from the NHS UK ServiceDesk API, specifically from the incident table. The API endpoint is https://servicedesk.NHS.UK.gov.com/api/now/table/incident.
I am sure some of you might have faced/come across with the error below when you are trying to connect to any API in Power Query.
I have got a solution for you. 🙂 😉
First Approach:
FullUrl = BaseUrl & Table & QueryParams & "&sysparm_offset=" & Text.From(Offset)
Second Approach:
Options = [
Headers=[Accept="application/json"],
Query = [
sysparm_fields = Text.From(Fields),
sysparm_query = Query,
sysparm_limit = Text.From(Limit),
sysparm_offset = Text.From(Offset),
sysparm_display_value = "true",
sysparm_exclude_reference_link = "true"
]
],
Source = Json.Document(Web.Contents(BaseUrl, Options)),
Data = try Source[result] otherwise null
in
Data,
First Approach:
Second Approach:
The second approach demonstrates a more reliable method for fetching data from APIs in Power BI, especially after publishing the dataset. By dynamically handling query parameters and constructing URLs within the Web.Contents function, you ensure compatibility and reduce the likelihood of errors. When working with Power BI and APIs, always use a method that dynamically manages query parameters for improved performance and reliability.
Let me know if you want the sample code or any questions on this. 🙂
@mwegener
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.