Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I've made several Rest API requests and the addresses are based on date parameters. However, at some periods the records are empty because there is no data to get, so the field of the record is missing. In this case other queries also are affected even if they are completely fine. What is the best method of handling this?
Solved! Go to Solution.
excellent. Use try ... otherwise ... in your M code. If the attempt to access the record fails then you know to ignore that (or do whatever you would do in that case)
Examine the API response. You will see subtle differences in the returned data that you can use to your advantage.
Here is a particularly harrowing example. In blatant ignorance of the web standards the gateway connection status response comes in empty when the connection is good, and returns a proper error message when not.
(GatewayId as text, ConnectionId as text) =>
let
JsonData = try Json.Document(Web.Contents("https://api.powerbi.com/v1.0/myorg/gateways/" & GatewayId & "/datasources/" & ConnectionId & "/status", [Headers=[Authorization=Authorization]])),
value = if JsonData[Error][Message]="We reached the end of the buffer." then "True" else "False"
in
value
So I have to specifically look for an error message "We reached the end of the buffer" to know that the connection is working fine. Boggles the mind.
This is the response when there is data:
And this comes when there is no data:
excellent. Use try ... otherwise ... in your M code. If the attempt to access the record fails then you know to ignore that (or do whatever you would do in that case)
Thanks! I created a table with the existing names of columns for the calculations as result of otherwise. Works fine.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
75 | |
73 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |