Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello all. I am a PowerBI beginner but have managed to cobble together the report I need that uses a function to get an access token from ServiceNow and then uses that access token to access the data. This is working perfectly.
However, my company is implementing a suggested security fix that will require the Bearer token in the post body instead of the header. I have no idea how to do this.
These are the lines of code I'm currently using to use the Access token to make the initial call:
accessToken = Get_Token(#"Client ID Dev", #"Client Secret Dev", #"Refresh Token Dev"),
Source = Json.Document(Web.Contents("https://{MyServiceNowInstance}.service-now.com/api/now/table/u_atf_test_suite_list?sysparm_display_value=true&sysparm_exclude_reference_link=true&sysparm_fields=test_name%2Csuite_test_suite%2Csuite_sys_scope%2Ctest_sys_scope%2Csuite_sys_created_on%2Ctest_sys_created_on%2Csuite_sys_updated_on%2Ctest_sys_updated_on", [Headers=[Authorization="Bearer " &accessToken]])),
Anyone able to help me? Please let me know if I need to provide more info.
Thank you,
Conan
Hi,
Thanks for the solution rajendraongole1 offered, and i want to offer some more information for user to refer to.
hello @ConanDLloyd , based on your description, you can put the authorization to a paramater, then put the paramater to the body, you can refer to the following link.
powerbi - How do I retrieve a bearer token from a service in Power BI? - Stack Overflow
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ConanDLloyd - You need to send the Bearer token in the request body instead of the header when making the API call to ServiceNow.
Unfortunately, Web.Contents in Power BI is primarily designed to pass tokens in the headers and does not directly support sending a Bearer token in the body for GET requests.
Code:
let
accessToken = Get_Token(#"Client ID Dev", #"Client Secret Dev", #"Refresh Token Dev"),
requestBody = "{ ""access_token"": """ & accessToken & """ }", // JSON body containing the token
Source = Json.Document(
Web.Contents(
"https://{MyServiceNowInstance}.service-now.com/api/now/table/u_atf_test_suite_list",
[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary(requestBody) // Send token in body
]
)
)
in
Source
Check with your ServiceNow API documentation to confirm if it supports sending the token this way.
Hope this helps.
Proud to be a Super User! | |