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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
this_is_pk
Regular Visitor

Date as Request Header in API

Hello all,

 

I am new to PBI and looking for some help here.

I am using a GET method to pull the data through API. According to the API documentation a dynamic bearer token is requried for every api call. I was able to fetch the token and when i was able to use it in the Request Headers for API URL. However according to the API documentation a Date Header is required which is UTC timezone to be sent along with Authorization token as Request Headers. Below is the code that i am using. 

 

Source = Value.Metadata(
Web.Contents(BaseURL,

[
Headers=[Authorization = Bearertoken, Date = TodaysDate
]
)),

 

However when i use Date in the Request Header the PBI is throwing an error 

 

Expression.Error: The 'Date' header must be modified using the appropriate property or method.
Parameter name: name
Details:
Sun, 05 May 2024 07:12:37 GMT

 

According the API Documentation the Header name should exactly match to the text whcih is "Date". I tried multiple options but nothing worked out. I also tried in Postman and when i use Date as Header it is working fine and when i change the Date name to any other name such as "Dates" (adding "s" at the end) even in postman i see 401 unauthorized error. I am not sure how to handle this.  Any help is greatly appreciated. 

5 REPLIES 5
lbendlin
Super User
Super User

Can you show the header for the successful Postman request?  Maybe the date format is expected to be in ISO-8601.

It is not the date format that is causing the issue. Its the header (such as column header) . 

For example Date = Sun, 05 May 2024 02:55:55 GMT - this is the format mentioned in API documentation. 

 

The format for date i have is correct but when i use the name "Date" the M query is returning errors. 

 

this_is_pk_0-1714935453435.png

 

 

Error that i am getting is below

 

this_is_pk_0-1714935715832.png

 

Try without the space.  I don't think that is the right date format, btw.

Power BI Access this date format without any issue. Please refer to this link below

 

Representation of date/time values in headers (REST API) - Azure Storage | Microsoft Learn

 

Also according to the API Documentation this is what i have

this_is_pk_0-1714980376048.png

 

 

Its the name of the Header that is causing the issue. You cant directly just write "Date" in M Query. But according the API documentation this is what it should be. Looking for some workaround here

 

 

If you have a Pro license you can open a Pro ticket at https://admin.powerplatform.microsoft.com/newsupportticket/powerbi
Otherwise you can raise an issue at https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues .

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors