Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Context
I’m using a service principal that has:
Power BI Admin role
Gateway Admin on the target Enterprise Gateway
Admin on the specific datasource/connection
The necessary API permissions (per MS docs for Gateways/Datasources)
Docs I’m following: https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource#examples
We rotate PAT tokens in Databricks on a schedule and want to update the corresponding Power BI gateway datasource (non-VNet gateway) whenever the PAT changes.
I used the sample from the Microsoft “Encrypt credentials” repo to encrypt the payload with the gateway’s public key:
https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/Python/Encrypt%20credentials
Goal
Automate PATCH /gateways/{gatewayId}/datasources/{datasourceId} to update the Databricks PAT for an existing gateway datasource.
Wondering if i an get some help with REST API i get this error no matter what i try - "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
Sample payload
"credentialDetails": {
"credentialType": "Key",
"credentials": "{\"credentialData\":[{\"name\":\"key\", \"value\":\"adad==\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "RSA-OAEP",
"privacyLevel": "None"
}
Solved! Go to Solution.
Yes, I validated with ChatGPT to confirm the payload was valid. However, I’m directly using the output generated from the localhost instance I set up following this GitHub sample. Has this approach worked for you others
Any suggestions here @Anonymous . I have tried manually updating the pat token through GUI that works same token encrypted with the gatewayid seems to not work
Hi @data_turke
Can you confirm when you are creating the new credentials from Databricks that it does not include any of the reserved characters used in base64 encoding?
Yes, I validated with ChatGPT to confirm the payload was valid. However, I’m directly using the output generated from the localhost instance I set up following this GitHub sample. Has this approach worked for you others
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 16 | |
| 14 | |
| 11 | |
| 9 | |
| 8 |
| User | Count |
|---|---|
| 36 | |
| 31 | |
| 29 | |
| 25 | |
| 25 |