Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello everyone!
I created a custom connector to interface with Facebook's API for PowerBI Desktop, and it functions perfectly, handling logins without issue. However, when I try to use it with PowerBI Service via the 'On-premises data gateway,' I encounter a login problem. Other custom connectors work fine, but the Facebook one does not.
Here's what happens:
At this point, it behaves just like it does on the desktop version. But instead of a successful login, after clicking the "create" button, I receive the following error:
PBI Test Gateway: [Expression.Error] The "code" field of the record was not found.
These are the (pretty standard) OAuth methods my connector is using:
OAuthLoginStart = (resourceUrl, state, display) => let AuthorizeUrl = authorize_Url & Uri.BuildQueryString([ client_id = app_id, redirect_uri = redirectUrl, scope=scopes, state = state ]) in [ LoginUri = AuthorizeUrl, CallbackUri = redirectUrl, WindowHeight = windowHeight, WindowWidth = windowWidth, Context = null ];
OAuthLoginFinish = (context, callbackUri, state) => let parts = Uri.Parts(callbackUri)[Query], result = if (Record.HasFields(parts, {"error", "error_description"})) then error Error.Record(parts[error], parts[error_description], parts) else TokenMethod(parts[code]) in result;
TokenMethod = (code) => let response = Web.Contents(token_Url & "?" & Uri.BuildQueryString([ client_id = app_id, redirect_uri = redirectUrl, client_secret = app_secret, code = code]), [ManualStatusHandling = {400}]), body = Json.Document(response), result = if (Record.HasFields(body, {"error", "error_description"})) then error Error.Record(body[error], body[error_description], body) else body in result;
Can anyone help resolve this issue?
Hi @SparkByte_202As a workaround, maybe you can use a 3rd party connector, it can save you a lot of time compared to the other options. I've tried windsor.ai, supermetrics and funnel.io. I stayed with windsor because it is much cheaper so just to let you know other options. In case you wonder, to make the connection first search for the Facebook Ads connector in the data sources list:
After that, just grant access to your Facebook Ads account using your credentials, then on preview and destination page you will see a preview of your FB fields:
There just select the fields you need. Finally, just select PBI as your data destination and finally just copy and paste the url on PBI --> Get Data --> Web --> Paste the url.
Hi, @SparkByte_202
Here are a few steps you can take to troubleshoot the issue and potentially resolve the issue. Verify the redirect URI to ensure that the URI specified in the OAuth method exactly matches the URI registered in the Facebook app settings. A mismatch in the redirect URI can cause issues during the OAuth flow.
Check the OAuth response and temporarily modify the connector code to record or output the full response received in the step. This can help you verify that the expected "tag" field is present in the response of the Facebook API.
Review the custom connector implementation: Make sure that the custom connector implements this section correctly, as this is required for the custom connector to work with the on-premises data gateway. You can check the following link:
Use custom data connectors with the on-premises data gateway - Power BI | Microsoft Learn
Another potential issue could be that the PowerBI service doesn't support custom functions. If you use any custom functions in Power Query, it can cause problems.
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.