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 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.
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
Source
Replace 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.