Forum Discussion
Rest API get call in power bi with headers and token
- 1 year ago
Thank you for using Microsoft Community Forum. thanks rohit1991 bhanu_gautam for your inputs. in addition am adding below points.
You don’t need to include all headers—only those required for the API call to succeed. Typically, this includes the Authorization header (e.g., Bearer YOUR_ACCESS_TOKEN), Content-Type (usually application/json), and any custom headers specified by the API documentation. In Power Query, headers are added in the Advanced Editor using M code, where you define them within a Headers record passed to the Web.Contents function. Power Query doesn't offer a separate UI for adding multiple headers, so you'll need to input them directly in the script. If you’re unsure which headers are necessary, start with the essentials and add others only if the API response indicates missing or invalid headers.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi CrouchingTiger ,
Step-by-step to call a REST API with headers and token in Power BI:
-
Start a Blank Query: In Power BI Desktop, go to Get Data > Blank Query, then open the Advanced Editor.
-
Write your API call using Web.Contents.
3.Load and transform: Power BI will load the JSON, and you can shape or expand it as needed.
Power BI Desktop will work with a manually generated token, but scheduled refresh in the Power BI Service doesn’t natively handle dynamic token refresh. If you need to automate token renewal, you might need to create a custom connector, or use an Azure Function/Logic App as an intermediate step. Make sure your token is valid and hasn’t expired. Double-check endpoint and headers if you get errors.
- CrouchingTiger1 year agoHelper I
Thank you for reply.
I have many headers.
And do I have to put in all headers in advanced option? In power query?
- v-priyankata1 year agoCommunity Support
Thank you for using Microsoft Community Forum. thanks rohit1991 bhanu_gautam for your inputs. in addition am adding below points.
You don’t need to include all headers—only those required for the API call to succeed. Typically, this includes the Authorization header (e.g., Bearer YOUR_ACCESS_TOKEN), Content-Type (usually application/json), and any custom headers specified by the API documentation. In Power Query, headers are added in the Advanced Editor using M code, where you define them within a Headers record passed to the Web.Contents function. Power Query doesn't offer a separate UI for adding multiple headers, so you'll need to input them directly in the script. If you’re unsure which headers are necessary, start with the essentials and add others only if the API response indicates missing or invalid headers.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.- v-priyankata1 year agoCommunity Support
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.