Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I'm trying to consume a REST API using the OData.Feed function, I have the URL and the bearer token to perform the request, but I'm getting the error:
"Expression.Error: OData: The header with name 'Headers' has a value type 'Record' that is invalid. Only DateTime, Logical, Number, and Text are supported."
The URL and the bearer token are valid, I can use them to perform a request in post man.
This is the code I'm trying to run (the token and the URL has been censored for security reasons):
let
token = "",
url = "",
//Source = OData.Feed(url, null, [Headers = [Authorization = token] ])
Source = OData.Feed(url, [Headers=[#" Authorization " = token]])
in
Source
The code has been inspired from the answer found here but the error message seems to be different.
Solved: Re: How authenticate to OData feed that uses Token... - Microsoft Fabric Community
Hi, @ECorona
The error message you're getting suggests that the headers you're passing to the OData.Feed function are not formatted correctly.
The OData.Feed function in Power Query M takes three parameters:
The problem seems to be with how you're passing your headers. You need to pass the headers as part of the options record, not the second parameter. The Authorization header usually starts with the word Bearer followed by a space and then the token.
Here's how you can correct your code:
let
token = "Bearer " & "<YourTokenHere>",
url = "<YourUrlHere>",
Source = OData.Feed(url, null, [Headers=[Authorization = token]])
in
Source
You replace <YourTokenHere> and <YourUrlHere> with your actual token and URL.
The corrected code passes the headers correctly, by including the Bearer keyword before the token. This is the standard way of passing bearer tokens in the Authorization header.
refer:
https://learn.microsoft.com/en-us/powerquery-m/odata-feed
Proud to be a Super User!
Hello,
I'd like to ask, if I'm gonna use two headers for my odata source, what would the format of the query would be? Is it like this?
Source = OData.Feed(url, null, [Headers=[Authorization = token], [customheader = key])
Thank a bunch!
User | Count |
---|---|
11 | |
8 | |
5 | |
5 | |
4 |
User | Count |
---|---|
16 | |
14 | |
8 | |
6 | |
6 |