Forum Discussion
Composite Mode Doesn't Work
- 10 months ago
Hi bubbledep ,
Thank you for sharing the additional details. The errors you’re seeing indicate that the current connection and authentication setup doesn’t align with what the Notion API requires. Unlike anonymous access, the Notion API needs an API token sent in the request headers for authentication. Because of this, setting the authentication to Anonymous will cause connection failures and bad request errors. To resolve this, you should use Power BI’s Web connector with a custom query that includes your Notion integration token as a Bearer token in the Authorization header. In Power Query Editor, you can use the Web.Contents function to call the API endpoint and pass the necessary headers, including the Authorization header and the Notion Version header. This way, authentication is handled correctly and should prevent the errors you’ve been encountering. Also, be sure your API request is formatted properly, especially if you’re making a POST request with a request body. For privacy levels, Organizational usually works well, but if issues persist, trying None temporarily can help with troubleshooting.
Hi DataNinja777 ,
Thanks for the suggestions. Unfortunately, that solution didn't worked 100%, I'll post some details below.
When trying to configure a new connection for the Notion REST API dataset, like you suggested in "For the Notion REST API, you will likely create a "Web" connection and set its authentication to Anonymous.", I'm getting the error "Unable to create connection for the following reason: Unable to connect to the data source. Either the data source is inaccessible, a connection timeout occurred, or the data source credentials are invalid. Please verify the data source configuration and contact a data source administrator to troubleshoot this issue."
Also, when I try to configure the credentials for that dataset as "Anonymous" for authentication method and "Organizational" for privacy level, I'm getting the error "Failed to update data source credentials: Web.Contents failed to get contents from 'https://api.notion.com/v1/databases/example/query' (400): Bad Request".
Thanks for the effort and help, but do you have any other suggestions?
Hi bubbledep ,
Thank you for sharing the additional details. The errors you’re seeing indicate that the current connection and authentication setup doesn’t align with what the Notion API requires. Unlike anonymous access, the Notion API needs an API token sent in the request headers for authentication. Because of this, setting the authentication to Anonymous will cause connection failures and bad request errors. To resolve this, you should use Power BI’s Web connector with a custom query that includes your Notion integration token as a Bearer token in the Authorization header. In Power Query Editor, you can use the Web.Contents function to call the API endpoint and pass the necessary headers, including the Authorization header and the Notion Version header. This way, authentication is handled correctly and should prevent the errors you’ve been encountering. Also, be sure your API request is formatted properly, especially if you’re making a POST request with a request body. For privacy levels, Organizational usually works well, but if issues persist, trying None temporarily can help with troubleshooting.
- fabric-excel10 months agoFrequent Visitor
Hi v-sshirivolu ,
In the Power BI Desktop I did that setup, and it's all good. That error is a problem that happens in the Power BI Service.
- v-sshirivolu10 months agoCommunity Support
Hi fabric-excel ,
This happens because Power BI Service handles web API connections differently than Desktop, especially for custom APIs that need a manual authentication token. Try to fix this is to split your URL into a static base and the endpoint path. For example:
let
baseUrl = "https://api.notion.com",
endpoint = "v1/databases/YOUR_DATABASE_ID/query",
body = "{}",Source = Json.Document(
Web.Contents(
baseUrl,
[
RelativePath = endpoint,
Headers = [
Authorization = "Bearer YOUR_SECRET_TOKEN",
#"Notion-Version" = "2022-06-28",
#"Content-Type" = "application/json"
],
Content = Text.ToBinary(body)
]
)
)
in
SourceReplace YOUR_SECRET_TOKEN and YOUR_DATABASE_ID with your real values. This structure helps Power BI Service refresh your data without issues.
After publishing, go to Power BI Service, Settings, Datasets, Data Source Credentials, select your web data source, set Authentication Method to Anonymous, and choose a privacy level as Organizational or Public. Save the changes. Since the token is already in the header, Power BI Service doesn’t need to handle complicated login flows. You can also update the token easily without changing the query.