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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.