Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ConanDLloyd
New Member

Pass Oauth credentials in body instead of header?

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

2 REPLIES 2
Anonymous
Not applicable

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.

 

rajendraongole1
Super User
Super User

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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors