<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Custom connector for Power BI source rest API with Oauth2 authentication in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-connector-for-Power-BI-source-rest-API-with-Oauth2/m-p/3368554#M43772</link>
    <description>&lt;P&gt;We are developing dashboards by connecting to the ERP (Finnegans) through an API REST with AOuth2.&lt;/P&gt;&lt;P&gt;We developed an M code in Power Query to connect with the data and published dashboards to Power BI Service, where they can be viewed correctly. However, the issue we are facing is that we are unable to schedule automatic refreshes “the following data sources don’t support refresh”&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TecnoIsowean_0-1691416313313.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/952173i8193819FDEE8AD2D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TecnoIsowean_0-1691416313313.png" alt="TecnoIsowean_0-1691416313313.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We understand that this error is because the API connection is generated using a dynamic Access Token under the OAuth2 protocol.&amp;nbsp;While researching online, we came across the following link, that suggests creating a Custom Connector to address this issue: &lt;A href="https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/" target="_blank" rel="noopener"&gt;https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We've managed to create a custom connector that with the API that gets the connection token to the ERP (Finnegans) API in Visual Studio:&lt;/P&gt;&lt;P&gt;----Code in VS&lt;/P&gt;&lt;P&gt;section FinnegansFede2; [DataSource.Kind="FinnegansFede2", Publish="FinnegansFede2.Publish"] shared FinnegansFede2.Contents = () =&amp;gt; &amp;nbsp; &amp;nbsp; let &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Definición de los datos de autenticación &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UrlBase1 = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RelativePathValue1 = "api/oauth/token", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GrantTypeParam = "grant_type=" &amp;amp; Uri.EscapeDataString("client_credentials"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ClientIdParam = "client_id=" &amp;amp; Uri.EscapeDataString("48695d6c4b7b95915165a72e4e7e0631"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ClientSecretParam = "client_secret=" &amp;amp; Uri.EscapeDataString("51381fb4d17416da53ca9d507dbb221g"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; QueryString1 = GrantTypeParam &amp;amp; "&amp;amp;" &amp;amp; ClientIdParam &amp;amp; "&amp;amp;" &amp;amp; ClientSecretParam, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FullUrl1 = UrlBase1 &amp;amp; RelativePathValue1 &amp;amp; "?" &amp;amp; QueryString1, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tokeni = Text.FromBinary(Web.Contents(FullUrl1)), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Construcción del token de acceso (Access Token) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccessToken = Uri.EscapeDataString(tokeni) &amp;nbsp; &amp;nbsp; in &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccessToken; // Data Source Kind description FinnegansFede2 = [ &amp;nbsp; &amp;nbsp; Authentication = [ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Basic = [] &amp;nbsp; &amp;nbsp; ], &amp;nbsp; &amp;nbsp; Label = Extension.LoadString("DataSourceLabel") ]; // Data Source UI publishing description FinnegansFede2.Publish = [ &amp;nbsp; &amp;nbsp; Beta = true, &amp;nbsp; &amp;nbsp; Category = "Other", &amp;nbsp; &amp;nbsp; ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") }, &amp;nbsp; &amp;nbsp; LearnMoreUrl = "&lt;A href="https://powerbi.microsoft.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://powerbi.microsoft.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; SourceImage = FinnegansFede2.Icons, &amp;nbsp; &amp;nbsp; SourceTypeImage = FinnegansFede2.Icons ]; FinnegansFede2.Icons = [ &amp;nbsp; &amp;nbsp; Icon16 = { Extension.Contents("FinnegansFede216.png"), Extension.Contents("FinnegansFede220.png"), Extension.Contents("FinnegansFede224.png"), Extension.Contents("FinnegansFede232.png") }, &amp;nbsp; &amp;nbsp; Icon32 = { Extension.Contents("FinnegansFede232.png"), Extension.Contents("FinnegansFede240.png"), Extension.Contents("FinnegansFede248.png"), Extension.Contents("FinnegansFede264.png") } ];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;We used this connector into Power BI Desktop and successfully published it to Power BI Service and established automatic refreshes by setting up an On-premises Gateway.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TecnoIsowean_2-1691416313324.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/952174i4E68C98196930A68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TecnoIsowean_2-1691416313324.png" alt="TecnoIsowean_2-1691416313324.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now we’re struggling to build a connector with the Api that brings the actual Data. We’ve tried two ways and failed in both:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We used the custom connector previously mentioned that brings the token (Origen1) in Power Query M query to obtain the table. The code is as follows:&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;-------------M code&lt;/P&gt;&lt;DIV&gt;let &amp;nbsp; &amp;nbsp; Origen1 = FinnegansFede2.Contents(null), &amp;nbsp; &amp;nbsp; FechaDesdeParam = "FechaDesde=" &amp;amp; Uri.EscapeDataString(desde), &amp;nbsp; &amp;nbsp; FechaHastaParam = "FechaHasta=" &amp;amp; Uri.EscapeDataString(hasta), &amp;nbsp; &amp;nbsp; DimensionParam = "PARAMWEBREPORT_dimension=" &amp;amp; Uri.EscapeDataString("DIMCTC"), &amp;nbsp; &amp;nbsp; EmpresaParam = "PARAMEmpresa=" &amp;amp; Uri.EscapeDataString("EMPRE01"), &amp;nbsp; &amp;nbsp; QueryString = Origen1 &amp;amp; "&amp;amp;" &amp;amp; FechaDesdeParam &amp;amp; "&amp;amp;" &amp;amp; FechaHastaParam &amp;amp; "&amp;amp;" &amp;amp; DimensionParam &amp;amp; "&amp;amp;" &amp;amp; EmpresaParam, &amp;nbsp; &amp;nbsp; UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW", &amp;nbsp; &amp;nbsp; FullUrl = UrlBase &amp;amp; RelativePathValue &amp;amp; "?" &amp;amp; QueryString, &amp;nbsp; &amp;nbsp; Origen = Json.Document(Web.Contents(FullUrl)), &amp;nbsp; &amp;nbsp; DatosOriginales = Table.FromList(Origen, Splitter.SplitByNothing(), null, null, ExtraValues.Error)&lt;/DIV&gt;&lt;DIV&gt;in&lt;/DIV&gt;&lt;DIV&gt;DatosOriginales&lt;/DIV&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;This works within Power BI Desktop and allows us to publish. However, the error while attempting to schedule automatic refresh remains (the following data sources don’t support refresh…”). Since the API for the data is still in the M code we didn’t solve the issue.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We’ve tried developing a Custom Connector in Visual Studio for the actual data, instead of just bringing the token. The code looks like this:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;// This file contains your Data Connector logic&lt;BR /&gt;section Finnegans;&lt;/P&gt;&lt;P&gt;[DataSource.Kind="Finnegans", Publish="Finnegans.Publish"]&lt;BR /&gt;shared Finnegans.Contents = (optional message as text) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;UrlBase1 = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;",&lt;BR /&gt;RelativePathValue1 = "api/oauth/token",&lt;BR /&gt;GrantTypeParam = "grant_type=" &amp;amp; Uri.EscapeDataString("client_credentials"),&lt;BR /&gt;ClientIdParam = "client_id=" &amp;amp; Uri.EscapeDataString("48695d6c4b7b95915165a72e4e7e0631"),&lt;BR /&gt;ClientSecretParam = "client_secret=" &amp;amp; Uri.EscapeDataString("51381fb4d17416da53ca9d507dbb221f"),&lt;BR /&gt;QueryString1 = GrantTypeParam &amp;amp; "&amp;amp;" &amp;amp; ClientIdParam &amp;amp; "&amp;amp;" &amp;amp; ClientSecretParam,&lt;BR /&gt;FullUrl1 = UrlBase1 &amp;amp; RelativePathValue1 &amp;amp; "?" &amp;amp; QueryString1,&lt;BR /&gt;tokeni = Text.FromBinary(Web.Contents(FullUrl1)),&lt;BR /&gt;UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;",&lt;BR /&gt;RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW",&lt;BR /&gt;AccessToken = "ACCESS_TOKEN=" &amp;amp; Uri.EscapeDataString(tokeni),&lt;BR /&gt;FechaDesdeParam = "FechaDesde=" &amp;amp; Uri.EscapeDataString("2023-07-01"),&lt;BR /&gt;FechaHastaParam = "FechaHasta=" &amp;amp; Uri.EscapeDataString("2023-07-05"),&lt;BR /&gt;DimensionParam = "PARAMWEBREPORT_dimension=" &amp;amp; Uri.EscapeDataString("DIMCTC"),&lt;BR /&gt;EmpresaParam = "PARAMEmpresa=" &amp;amp; Uri.EscapeDataString("EMPRE01"),&lt;BR /&gt;QueryString = AccessToken &amp;amp; "&amp;amp;" &amp;amp; FechaDesdeParam &amp;amp; "&amp;amp;" &amp;amp; FechaHastaParam &amp;amp; "&amp;amp;" &amp;amp; DimensionParam &amp;amp; "&amp;amp;" &amp;amp; EmpresaParam,&lt;BR /&gt;FullUrl = UrlBase &amp;amp; RelativePathValue &amp;amp; "?" &amp;amp; QueryString,&lt;BR /&gt;Origen = Json.Document(Web.Contents(FullUrl)),&lt;BR /&gt;DatosOriginales = Table.FromList(Origen, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;#"Se expandió Column1" = Table.ExpandRecordColumn(DatosOriginales, "Column1", {"TRANSACCIONSUBTIPOID", "IDDOCUMENTO", "CELULA", "FECHA", "FECHACOMPROBANTE", "TRANSACCIONTIPONOMBRE", "TIPODOCUMENTO", "TRANSACCIONID", "DOCNROINT", "COMPROBANTE", "COMPROBANTEADICIONAL", "NUMEROCONTRATO", "DIMENSIONVALOR", "TOTALBRUTO", "TOTALCONCEPTOS", "TOTAL", "CLIENTE", "CUIT", "DESCRIPCION", "CONDICIONPAGO", "MONEDA", "COTIZACION", "LISTAPRECIO", "VENDEDOR", "PRODUCTO", "MARCA", "DESCITEM", "CANTIDAD", "CANTIDADSTOCK2", "UNIDADVENTA", "UNIDADCOMPRA", "UNIDADSTOCK", "UNIDADSTOCK2", "PRECIO", "PRECIOMONPRINCIPAL", "PRECIOMONSECUNDARIA", "IMPORTEMONPRINCIPAL", "IMPORTEMONSECUNDARIA", "DEPOSITOORIGEN", "DEPOSITODESTINO", "PRECIOSOBRE", "IMPORTE", "GRAVADO", "NO GRAVADO", "PROVEEDOR", "PARTIDA", "ESTADO", "CODIGOPROD", "PENDIENTEORIGEN", "PENDIENTEDESTINO", "IMPORTEPENDIENTEORIGEN", "IMPORTEPENDIENTEDESTINO", "ORGANIZACION", "CUENTA", "EMPRESA", "ANO", "ANO-MES", "PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "PORCENTAJEIMPOSITIVO", "CONTROLIMPOSITIVO3", "GRAVADOPORTASAIMPOSITIVA", "GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", "@@CLASEVO", "FECHAPROXIMOPASO", "SEMANACARGADESDE", "SEMANACARGAHASTA", "PROVINCIADESTINO", "PROVINCIAORIGEN", "COORDENADAS", "CORREDOR", "SUCURSAL", "CAI/CAE", "NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE", "PROVINCIADESTINOITEM", "PERCEPCIONES", "SUBFAMILIA", "FAMILIA", "RUBRO", "ACTIVIDADIVA", "WORKFLOW", "IDENTIFICACIONEXTERNA", "ETAPAS DE OBRA"}, {"TRANSACCIONSUBTIPOID", "IDDOCUMENTO", "CELULA", "FECHA", "FECHACOMPROBANTE", "TRANSACCIONTIPONOMBRE", "TIPODOCUMENTO", "TRANSACCIONID", "DOCNROINT", "COMPROBANTE", "COMPROBANTEADICIONAL", "NUMEROCONTRATO", "DIMENSIONVALOR", "TOTALBRUTO", "TOTALCONCEPTOS", "TOTAL", "CLIENTE", "CUIT", "DESCRIPCION", "CONDICIONPAGO", "MONEDA", "COTIZACION", "LISTAPRECIO", "VENDEDOR", "PRODUCTO", "MARCA", "DESCITEM", "CANTIDAD", "CANTIDADSTOCK2", "UNIDADVENTA", "UNIDADCOMPRA", "UNIDADSTOCK", "UNIDADSTOCK2", "PRECIO", "PRECIOMONPRINCIPAL", "PRECIOMONSECUNDARIA", "IMPORTEMONPRINCIPAL", "IMPORTEMONSECUNDARIA", "DEPOSITOORIGEN", "DEPOSITODESTINO", "PRECIOSOBRE", "IMPORTE", "GRAVADO", "NO GRAVADO", "PROVEEDOR", "PARTIDA", "ESTADO", "CODIGOPROD", "PENDIENTEORIGEN", "PENDIENTEDESTINO", "IMPORTEPENDIENTEORIGEN", "IMPORTEPENDIENTEDESTINO", "ORGANIZACION", "CUENTA", "EMPRESA", "ANO", "ANO-MES", "PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "PORCENTAJEIMPOSITIVO", "CONTROLIMPOSITIVO3", "GRAVADOPORTASAIMPOSITIVA", "GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", "@@CLASEVO", "FECHAPROXIMOPASO", "SEMANACARGADESDE", "SEMANACARGAHASTA", "PROVINCIADESTINO", "PROVINCIAORIGEN", "COORDENADAS", "CORREDOR", "SUCURSAL", "CAI/CAE", "NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE", "PROVINCIADESTINOITEM", "PERCEPCIONES", "SUBFAMILIA", "FAMILIA", "RUBRO", "ACTIVIDADIVA", "WORKFLOW", "IDENTIFICACIONEXTERNA", "ETAPAS DE OBRA"}),&lt;BR /&gt;#"Tipo cambiado" = Table.TransformColumnTypes(#"Se expandió Column1",{{"FECHA", type date}, {"FECHACOMPROBANTE", type date}}),&lt;BR /&gt;#"Columnas quitadas" = Table.RemoveColumns(#"Tipo cambiado",{"COMPROBANTEADICIONAL", "NUMEROCONTRATO"}),&lt;BR /&gt;#"Tipo cambiado1" = Table.TransformColumnTypes(#"Columnas quitadas",{{"TOTALBRUTO", Currency.Type}, {"TOTALCONCEPTOS", Currency.Type}, {"TOTAL", Currency.Type}, {"COTIZACION", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas1" = Table.RemoveColumns(#"Tipo cambiado1",{"MARCA"}),&lt;BR /&gt;#"Tipo cambiado2" = Table.TransformColumnTypes(#"Columnas quitadas1",{{"CANTIDAD", type number}, {"CANTIDADSTOCK2", type number}, {"PRECIO", Currency.Type}, {"PRECIOMONPRINCIPAL", Currency.Type}, {"PRECIOMONSECUNDARIA", Currency.Type}, {"IMPORTEMONPRINCIPAL", Currency.Type}, {"IMPORTEMONSECUNDARIA", Currency.Type}, {"IMPORTE", Currency.Type}, {"GRAVADO", Currency.Type}, {"NO GRAVADO", Currency.Type}, {"PENDIENTEORIGEN", type number}, {"PENDIENTEDESTINO", type number}, {"IMPORTEPENDIENTEORIGEN", Currency.Type}, {"IMPORTEPENDIENTEDESTINO", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas2" = Table.RemoveColumns(#"Tipo cambiado2",{"PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "CONTROLIMPOSITIVO3"}),&lt;BR /&gt;#"Tipo cambiado3" = Table.TransformColumnTypes(#"Columnas quitadas2",{{"PORCENTAJEIMPOSITIVO", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas3" = Table.RemoveColumns(#"Tipo cambiado3",{"ACTIVIDADIVA"}),&lt;BR /&gt;#"Tipo cambiado4" = Table.TransformColumnTypes(#"Columnas quitadas3",{{"GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", Currency.Type}, {"GRAVADOPORTASAIMPOSITIVA", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas4" = Table.RemoveColumns(#"Tipo cambiado4",{"NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE"}),&lt;BR /&gt;#"Tipo cambiado5" = Table.TransformColumnTypes(#"Columnas quitadas4",{{"PERCEPCIONES", Currency.Type}})&lt;BR /&gt;in&lt;BR /&gt;#"Tipo cambiado5";&lt;/P&gt;&lt;P&gt;// Data Source Kind description&lt;BR /&gt;Finnegans = [&lt;BR /&gt;Authentication = [&lt;BR /&gt;// Key = [],&lt;BR /&gt;// UsernamePassword = [],&lt;BR /&gt;// Windows = [],&lt;BR /&gt;Anonymous = []&lt;BR /&gt;],&lt;BR /&gt;Label = Extension.LoadString("DataSourceLabel")&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;// Data Source UI publishing description&lt;BR /&gt;Finnegans.Publish = [&lt;BR /&gt;Beta = true,&lt;BR /&gt;Category = "Other",&lt;BR /&gt;ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },&lt;BR /&gt;LearnMoreUrl = "&lt;A href="https://powerbi.microsoft.com/" target="_blank" rel="noopener"&gt;https://powerbi.microsoft.com/&lt;/A&gt;",&lt;BR /&gt;SourceImage = Finnegans.Icons,&lt;BR /&gt;SourceTypeImage = Finnegans.Icons&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Finnegans.Icons = [&lt;BR /&gt;Icon16 = { Extension.Contents("Finnegans16.png"), Extension.Contents("Finnegans20.png"), Extension.Contents("Finnegans24.png"), Extension.Contents("Finnegans32.png") },&lt;BR /&gt;Icon32 = { Extension.Contents("Finnegans32.png"), Extension.Contents("Finnegans40.png"), Extension.Contents("Finnegans48.png"), Extension.Contents("Finnegans64.png") }&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When executed in Visual Studio without specifying the connection method, the following error appears:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After manually setting CREDENTIAL TYPE to Anonymous, the code functions correctly and returns the desired table:&lt;/P&gt;&lt;P&gt;When attempting to use the connector in Power BI Desktop, the following error pops up:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We believe that there is an issue in the connector development that is preventing us from using it in Power BI Desktop, and presumably it has something to do with the error that pops up in Visual and made us manually set CREDENTIAL TYPE to Anonymous or the fact that it needs to first bring the Token and then the data set.&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2023 14:14:04 GMT</pubDate>
    <dc:creator>TecnoIsowean</dc:creator>
    <dc:date>2023-08-07T14:14:04Z</dc:date>
    <item>
      <title>Custom connector for Power BI source rest API with Oauth2 authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-connector-for-Power-BI-source-rest-API-with-Oauth2/m-p/3368554#M43772</link>
      <description>&lt;P&gt;We are developing dashboards by connecting to the ERP (Finnegans) through an API REST with AOuth2.&lt;/P&gt;&lt;P&gt;We developed an M code in Power Query to connect with the data and published dashboards to Power BI Service, where they can be viewed correctly. However, the issue we are facing is that we are unable to schedule automatic refreshes “the following data sources don’t support refresh”&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TecnoIsowean_0-1691416313313.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/952173i8193819FDEE8AD2D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TecnoIsowean_0-1691416313313.png" alt="TecnoIsowean_0-1691416313313.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We understand that this error is because the API connection is generated using a dynamic Access Token under the OAuth2 protocol.&amp;nbsp;While researching online, we came across the following link, that suggests creating a Custom Connector to address this issue: &lt;A href="https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/" target="_blank" rel="noopener"&gt;https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We've managed to create a custom connector that with the API that gets the connection token to the ERP (Finnegans) API in Visual Studio:&lt;/P&gt;&lt;P&gt;----Code in VS&lt;/P&gt;&lt;P&gt;section FinnegansFede2; [DataSource.Kind="FinnegansFede2", Publish="FinnegansFede2.Publish"] shared FinnegansFede2.Contents = () =&amp;gt; &amp;nbsp; &amp;nbsp; let &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Definición de los datos de autenticación &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UrlBase1 = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RelativePathValue1 = "api/oauth/token", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GrantTypeParam = "grant_type=" &amp;amp; Uri.EscapeDataString("client_credentials"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ClientIdParam = "client_id=" &amp;amp; Uri.EscapeDataString("48695d6c4b7b95915165a72e4e7e0631"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ClientSecretParam = "client_secret=" &amp;amp; Uri.EscapeDataString("51381fb4d17416da53ca9d507dbb221g"), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; QueryString1 = GrantTypeParam &amp;amp; "&amp;amp;" &amp;amp; ClientIdParam &amp;amp; "&amp;amp;" &amp;amp; ClientSecretParam, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FullUrl1 = UrlBase1 &amp;amp; RelativePathValue1 &amp;amp; "?" &amp;amp; QueryString1, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tokeni = Text.FromBinary(Web.Contents(FullUrl1)), &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Construcción del token de acceso (Access Token) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW", &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccessToken = Uri.EscapeDataString(tokeni) &amp;nbsp; &amp;nbsp; in &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AccessToken; // Data Source Kind description FinnegansFede2 = [ &amp;nbsp; &amp;nbsp; Authentication = [ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Basic = [] &amp;nbsp; &amp;nbsp; ], &amp;nbsp; &amp;nbsp; Label = Extension.LoadString("DataSourceLabel") ]; // Data Source UI publishing description FinnegansFede2.Publish = [ &amp;nbsp; &amp;nbsp; Beta = true, &amp;nbsp; &amp;nbsp; Category = "Other", &amp;nbsp; &amp;nbsp; ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") }, &amp;nbsp; &amp;nbsp; LearnMoreUrl = "&lt;A href="https://powerbi.microsoft.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://powerbi.microsoft.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; SourceImage = FinnegansFede2.Icons, &amp;nbsp; &amp;nbsp; SourceTypeImage = FinnegansFede2.Icons ]; FinnegansFede2.Icons = [ &amp;nbsp; &amp;nbsp; Icon16 = { Extension.Contents("FinnegansFede216.png"), Extension.Contents("FinnegansFede220.png"), Extension.Contents("FinnegansFede224.png"), Extension.Contents("FinnegansFede232.png") }, &amp;nbsp; &amp;nbsp; Icon32 = { Extension.Contents("FinnegansFede232.png"), Extension.Contents("FinnegansFede240.png"), Extension.Contents("FinnegansFede248.png"), Extension.Contents("FinnegansFede264.png") } ];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;We used this connector into Power BI Desktop and successfully published it to Power BI Service and established automatic refreshes by setting up an On-premises Gateway.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TecnoIsowean_2-1691416313324.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/952174i4E68C98196930A68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TecnoIsowean_2-1691416313324.png" alt="TecnoIsowean_2-1691416313324.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now we’re struggling to build a connector with the Api that brings the actual Data. We’ve tried two ways and failed in both:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We used the custom connector previously mentioned that brings the token (Origen1) in Power Query M query to obtain the table. The code is as follows:&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;-------------M code&lt;/P&gt;&lt;DIV&gt;let &amp;nbsp; &amp;nbsp; Origen1 = FinnegansFede2.Contents(null), &amp;nbsp; &amp;nbsp; FechaDesdeParam = "FechaDesde=" &amp;amp; Uri.EscapeDataString(desde), &amp;nbsp; &amp;nbsp; FechaHastaParam = "FechaHasta=" &amp;amp; Uri.EscapeDataString(hasta), &amp;nbsp; &amp;nbsp; DimensionParam = "PARAMWEBREPORT_dimension=" &amp;amp; Uri.EscapeDataString("DIMCTC"), &amp;nbsp; &amp;nbsp; EmpresaParam = "PARAMEmpresa=" &amp;amp; Uri.EscapeDataString("EMPRE01"), &amp;nbsp; &amp;nbsp; QueryString = Origen1 &amp;amp; "&amp;amp;" &amp;amp; FechaDesdeParam &amp;amp; "&amp;amp;" &amp;amp; FechaHastaParam &amp;amp; "&amp;amp;" &amp;amp; DimensionParam &amp;amp; "&amp;amp;" &amp;amp; EmpresaParam, &amp;nbsp; &amp;nbsp; UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;", &amp;nbsp; &amp;nbsp; RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW", &amp;nbsp; &amp;nbsp; FullUrl = UrlBase &amp;amp; RelativePathValue &amp;amp; "?" &amp;amp; QueryString, &amp;nbsp; &amp;nbsp; Origen = Json.Document(Web.Contents(FullUrl)), &amp;nbsp; &amp;nbsp; DatosOriginales = Table.FromList(Origen, Splitter.SplitByNothing(), null, null, ExtraValues.Error)&lt;/DIV&gt;&lt;DIV&gt;in&lt;/DIV&gt;&lt;DIV&gt;DatosOriginales&lt;/DIV&gt;&lt;P&gt;---------------------------&lt;/P&gt;&lt;P&gt;This works within Power BI Desktop and allows us to publish. However, the error while attempting to schedule automatic refresh remains (the following data sources don’t support refresh…”). Since the API for the data is still in the M code we didn’t solve the issue.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We’ve tried developing a Custom Connector in Visual Studio for the actual data, instead of just bringing the token. The code looks like this:&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;// This file contains your Data Connector logic&lt;BR /&gt;section Finnegans;&lt;/P&gt;&lt;P&gt;[DataSource.Kind="Finnegans", Publish="Finnegans.Publish"]&lt;BR /&gt;shared Finnegans.Contents = (optional message as text) =&amp;gt;&lt;BR /&gt;let&lt;BR /&gt;UrlBase1 = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;",&lt;BR /&gt;RelativePathValue1 = "api/oauth/token",&lt;BR /&gt;GrantTypeParam = "grant_type=" &amp;amp; Uri.EscapeDataString("client_credentials"),&lt;BR /&gt;ClientIdParam = "client_id=" &amp;amp; Uri.EscapeDataString("48695d6c4b7b95915165a72e4e7e0631"),&lt;BR /&gt;ClientSecretParam = "client_secret=" &amp;amp; Uri.EscapeDataString("51381fb4d17416da53ca9d507dbb221f"),&lt;BR /&gt;QueryString1 = GrantTypeParam &amp;amp; "&amp;amp;" &amp;amp; ClientIdParam &amp;amp; "&amp;amp;" &amp;amp; ClientSecretParam,&lt;BR /&gt;FullUrl1 = UrlBase1 &amp;amp; RelativePathValue1 &amp;amp; "?" &amp;amp; QueryString1,&lt;BR /&gt;tokeni = Text.FromBinary(Web.Contents(FullUrl1)),&lt;BR /&gt;UrlBase = "&lt;A href="https://api.teamplace.finneg.com/" target="_blank" rel="noopener"&gt;https://api.teamplace.finneg.com/&lt;/A&gt;",&lt;BR /&gt;RelativePathValue = "api/reports/USR_ANALISISDEFACTURADECOMPRAISW",&lt;BR /&gt;AccessToken = "ACCESS_TOKEN=" &amp;amp; Uri.EscapeDataString(tokeni),&lt;BR /&gt;FechaDesdeParam = "FechaDesde=" &amp;amp; Uri.EscapeDataString("2023-07-01"),&lt;BR /&gt;FechaHastaParam = "FechaHasta=" &amp;amp; Uri.EscapeDataString("2023-07-05"),&lt;BR /&gt;DimensionParam = "PARAMWEBREPORT_dimension=" &amp;amp; Uri.EscapeDataString("DIMCTC"),&lt;BR /&gt;EmpresaParam = "PARAMEmpresa=" &amp;amp; Uri.EscapeDataString("EMPRE01"),&lt;BR /&gt;QueryString = AccessToken &amp;amp; "&amp;amp;" &amp;amp; FechaDesdeParam &amp;amp; "&amp;amp;" &amp;amp; FechaHastaParam &amp;amp; "&amp;amp;" &amp;amp; DimensionParam &amp;amp; "&amp;amp;" &amp;amp; EmpresaParam,&lt;BR /&gt;FullUrl = UrlBase &amp;amp; RelativePathValue &amp;amp; "?" &amp;amp; QueryString,&lt;BR /&gt;Origen = Json.Document(Web.Contents(FullUrl)),&lt;BR /&gt;DatosOriginales = Table.FromList(Origen, Splitter.SplitByNothing(), null, null, ExtraValues.Error),&lt;BR /&gt;#"Se expandió Column1" = Table.ExpandRecordColumn(DatosOriginales, "Column1", {"TRANSACCIONSUBTIPOID", "IDDOCUMENTO", "CELULA", "FECHA", "FECHACOMPROBANTE", "TRANSACCIONTIPONOMBRE", "TIPODOCUMENTO", "TRANSACCIONID", "DOCNROINT", "COMPROBANTE", "COMPROBANTEADICIONAL", "NUMEROCONTRATO", "DIMENSIONVALOR", "TOTALBRUTO", "TOTALCONCEPTOS", "TOTAL", "CLIENTE", "CUIT", "DESCRIPCION", "CONDICIONPAGO", "MONEDA", "COTIZACION", "LISTAPRECIO", "VENDEDOR", "PRODUCTO", "MARCA", "DESCITEM", "CANTIDAD", "CANTIDADSTOCK2", "UNIDADVENTA", "UNIDADCOMPRA", "UNIDADSTOCK", "UNIDADSTOCK2", "PRECIO", "PRECIOMONPRINCIPAL", "PRECIOMONSECUNDARIA", "IMPORTEMONPRINCIPAL", "IMPORTEMONSECUNDARIA", "DEPOSITOORIGEN", "DEPOSITODESTINO", "PRECIOSOBRE", "IMPORTE", "GRAVADO", "NO GRAVADO", "PROVEEDOR", "PARTIDA", "ESTADO", "CODIGOPROD", "PENDIENTEORIGEN", "PENDIENTEDESTINO", "IMPORTEPENDIENTEORIGEN", "IMPORTEPENDIENTEDESTINO", "ORGANIZACION", "CUENTA", "EMPRESA", "ANO", "ANO-MES", "PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "PORCENTAJEIMPOSITIVO", "CONTROLIMPOSITIVO3", "GRAVADOPORTASAIMPOSITIVA", "GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", "@@CLASEVO", "FECHAPROXIMOPASO", "SEMANACARGADESDE", "SEMANACARGAHASTA", "PROVINCIADESTINO", "PROVINCIAORIGEN", "COORDENADAS", "CORREDOR", "SUCURSAL", "CAI/CAE", "NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE", "PROVINCIADESTINOITEM", "PERCEPCIONES", "SUBFAMILIA", "FAMILIA", "RUBRO", "ACTIVIDADIVA", "WORKFLOW", "IDENTIFICACIONEXTERNA", "ETAPAS DE OBRA"}, {"TRANSACCIONSUBTIPOID", "IDDOCUMENTO", "CELULA", "FECHA", "FECHACOMPROBANTE", "TRANSACCIONTIPONOMBRE", "TIPODOCUMENTO", "TRANSACCIONID", "DOCNROINT", "COMPROBANTE", "COMPROBANTEADICIONAL", "NUMEROCONTRATO", "DIMENSIONVALOR", "TOTALBRUTO", "TOTALCONCEPTOS", "TOTAL", "CLIENTE", "CUIT", "DESCRIPCION", "CONDICIONPAGO", "MONEDA", "COTIZACION", "LISTAPRECIO", "VENDEDOR", "PRODUCTO", "MARCA", "DESCITEM", "CANTIDAD", "CANTIDADSTOCK2", "UNIDADVENTA", "UNIDADCOMPRA", "UNIDADSTOCK", "UNIDADSTOCK2", "PRECIO", "PRECIOMONPRINCIPAL", "PRECIOMONSECUNDARIA", "IMPORTEMONPRINCIPAL", "IMPORTEMONSECUNDARIA", "DEPOSITOORIGEN", "DEPOSITODESTINO", "PRECIOSOBRE", "IMPORTE", "GRAVADO", "NO GRAVADO", "PROVEEDOR", "PARTIDA", "ESTADO", "CODIGOPROD", "PENDIENTEORIGEN", "PENDIENTEDESTINO", "IMPORTEPENDIENTEORIGEN", "IMPORTEPENDIENTEDESTINO", "ORGANIZACION", "CUENTA", "EMPRESA", "ANO", "ANO-MES", "PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "PORCENTAJEIMPOSITIVO", "CONTROLIMPOSITIVO3", "GRAVADOPORTASAIMPOSITIVA", "GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", "@@CLASEVO", "FECHAPROXIMOPASO", "SEMANACARGADESDE", "SEMANACARGAHASTA", "PROVINCIADESTINO", "PROVINCIAORIGEN", "COORDENADAS", "CORREDOR", "SUCURSAL", "CAI/CAE", "NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE", "PROVINCIADESTINOITEM", "PERCEPCIONES", "SUBFAMILIA", "FAMILIA", "RUBRO", "ACTIVIDADIVA", "WORKFLOW", "IDENTIFICACIONEXTERNA", "ETAPAS DE OBRA"}),&lt;BR /&gt;#"Tipo cambiado" = Table.TransformColumnTypes(#"Se expandió Column1",{{"FECHA", type date}, {"FECHACOMPROBANTE", type date}}),&lt;BR /&gt;#"Columnas quitadas" = Table.RemoveColumns(#"Tipo cambiado",{"COMPROBANTEADICIONAL", "NUMEROCONTRATO"}),&lt;BR /&gt;#"Tipo cambiado1" = Table.TransformColumnTypes(#"Columnas quitadas",{{"TOTALBRUTO", Currency.Type}, {"TOTALCONCEPTOS", Currency.Type}, {"TOTAL", Currency.Type}, {"COTIZACION", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas1" = Table.RemoveColumns(#"Tipo cambiado1",{"MARCA"}),&lt;BR /&gt;#"Tipo cambiado2" = Table.TransformColumnTypes(#"Columnas quitadas1",{{"CANTIDAD", type number}, {"CANTIDADSTOCK2", type number}, {"PRECIO", Currency.Type}, {"PRECIOMONPRINCIPAL", Currency.Type}, {"PRECIOMONSECUNDARIA", Currency.Type}, {"IMPORTEMONPRINCIPAL", Currency.Type}, {"IMPORTEMONSECUNDARIA", Currency.Type}, {"IMPORTE", Currency.Type}, {"GRAVADO", Currency.Type}, {"NO GRAVADO", Currency.Type}, {"PENDIENTEORIGEN", type number}, {"PENDIENTEDESTINO", type number}, {"IMPORTEPENDIENTEORIGEN", Currency.Type}, {"IMPORTEPENDIENTEDESTINO", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas2" = Table.RemoveColumns(#"Tipo cambiado2",{"PRODUCTORAMA1", "PRODUCTORAMA2", "PRODUCTORAMA3", "PRODUCTORAMAN", "CONTROLIMPOSITIVO3"}),&lt;BR /&gt;#"Tipo cambiado3" = Table.TransformColumnTypes(#"Columnas quitadas2",{{"PORCENTAJEIMPOSITIVO", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas3" = Table.RemoveColumns(#"Tipo cambiado3",{"ACTIVIDADIVA"}),&lt;BR /&gt;#"Tipo cambiado4" = Table.TransformColumnTypes(#"Columnas quitadas3",{{"GRAVADOPORTASAIMPOSITIVAMONEDAPRINCIPAL", Currency.Type}, {"GRAVADOPORTASAIMPOSITIVA", Currency.Type}}),&lt;BR /&gt;#"Columnas quitadas4" = Table.RemoveColumns(#"Tipo cambiado4",{"NIVEL1DIMENSION", "NIVEL2DIMENSION", "NIVEL1CLIENTE", "NIVEL2CLIENTE"}),&lt;BR /&gt;#"Tipo cambiado5" = Table.TransformColumnTypes(#"Columnas quitadas4",{{"PERCEPCIONES", Currency.Type}})&lt;BR /&gt;in&lt;BR /&gt;#"Tipo cambiado5";&lt;/P&gt;&lt;P&gt;// Data Source Kind description&lt;BR /&gt;Finnegans = [&lt;BR /&gt;Authentication = [&lt;BR /&gt;// Key = [],&lt;BR /&gt;// UsernamePassword = [],&lt;BR /&gt;// Windows = [],&lt;BR /&gt;Anonymous = []&lt;BR /&gt;],&lt;BR /&gt;Label = Extension.LoadString("DataSourceLabel")&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;// Data Source UI publishing description&lt;BR /&gt;Finnegans.Publish = [&lt;BR /&gt;Beta = true,&lt;BR /&gt;Category = "Other",&lt;BR /&gt;ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },&lt;BR /&gt;LearnMoreUrl = "&lt;A href="https://powerbi.microsoft.com/" target="_blank" rel="noopener"&gt;https://powerbi.microsoft.com/&lt;/A&gt;",&lt;BR /&gt;SourceImage = Finnegans.Icons,&lt;BR /&gt;SourceTypeImage = Finnegans.Icons&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Finnegans.Icons = [&lt;BR /&gt;Icon16 = { Extension.Contents("Finnegans16.png"), Extension.Contents("Finnegans20.png"), Extension.Contents("Finnegans24.png"), Extension.Contents("Finnegans32.png") },&lt;BR /&gt;Icon32 = { Extension.Contents("Finnegans32.png"), Extension.Contents("Finnegans40.png"), Extension.Contents("Finnegans48.png"), Extension.Contents("Finnegans64.png") }&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;-----------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When executed in Visual Studio without specifying the connection method, the following error appears:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After manually setting CREDENTIAL TYPE to Anonymous, the code functions correctly and returns the desired table:&lt;/P&gt;&lt;P&gt;When attempting to use the connector in Power BI Desktop, the following error pops up:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We believe that there is an issue in the connector development that is preventing us from using it in Power BI Desktop, and presumably it has something to do with the error that pops up in Visual and made us manually set CREDENTIAL TYPE to Anonymous or the fact that it needs to first bring the Token and then the data set.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 14:14:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-connector-for-Power-BI-source-rest-API-with-Oauth2/m-p/3368554#M43772</guid>
      <dc:creator>TecnoIsowean</dc:creator>
      <dc:date>2023-08-07T14:14:04Z</dc:date>
    </item>
  </channel>
</rss>

