<?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 Re: Custom Data Connector Power BI, fill List with json response in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/234080#M7372</link>
    <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/39322"&gt;@eramirez&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Could you zip your project from visual studio and share it with me?&lt;/P&gt;</description>
    <pubDate>Fri, 18 Aug 2017 10:07:52 GMT</pubDate>
    <dc:creator>Eric_Zhang</dc:creator>
    <dc:date>2017-08-18T10:07:52Z</dc:date>
    <item>
      <title>Custom Data Connector Power BI, fill List with json response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/232748#M7334</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a Custom Data Connector for Power Bi, which I want to display a list from a json response, if I hardcode the list the selector displays fine, but if I try to fill the selector with a json response, at the moment of open Power BI, shows me an error and my conector is not available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that shows me correctly my hardcoded list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;shared listTest = getDataFromUrl;

MyConnectorType = type function (
    count as (type text meta [
        Documentation.FieldCaption = "Count",
        Documentation.FieldDescription = "Number of times to repeat the message",
        Documentation.AllowedValues = listTest
    ]))
    as table meta [
        Documentation.Name = "Hello - Name",
        Documentation.LongDescription = "Hello - Long Description",
        Documentation.Examples = {[
            Description = "Another example, new message, new count!",
            Code = "HelloWorldWithDocs.Contents(""Goodbye"", 1)",
            Result = "#table({""Column1""}, {{""Goodbye""}})"
        ]}
    ];&lt;BR /&gt;&lt;BR /&gt;getDataFromUrl = &lt;BR /&gt; let&lt;BR /&gt; url = "http://localhost:8080/jsontest/",&lt;BR /&gt; source = Web.Contents(url, [ Headers = DefaultRequestHeaders ]),&lt;BR /&gt; xml = Xml.Tables(source),&lt;BR /&gt; SessionState = Table.ExpandTableColumn(xml,"session-states",{"min-state"}),&lt;BR /&gt; ss = Table.Column(SessionState,"min-state"),&lt;BR /&gt; reportArray = Table.Column(SessionState,"report-array"),&lt;BR /&gt; textJson = Lines.ToText(reportArray),&lt;BR /&gt; json = Json.Document(textJson),&lt;BR /&gt; ids = Table.FromRecords(json,{"name"}),&lt;BR /&gt; list = Table.ToList(ids),&lt;BR /&gt; test = {1,2,3}&lt;BR /&gt; in&lt;BR /&gt; list;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I return in the getDataFromUrl function test variable, Power BI shows me my plugin correctly with the elements from the list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="connector.PNG" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/55137iD70396C742B76094/image-size/large?v=v2&amp;amp;px=999" role="button" title="connector.PNG" alt="connector.PNG" /&gt;&lt;/span&gt;&lt;IMG src="https://ip1.i.lithium.com/d9b4e9e0bf4127c816112614628cb1eec60f9de6/68747470733a2f2f6962622e636f2f6e4459595261" border="0" width="704" height="223" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I change the return of my method to variable list, power BI gives me this error on launching:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="errorConnector.PNG" style="width: 460px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/55138i9A6AD45303EA6814/image-size/large?v=v2&amp;amp;px=999" role="button" title="errorConnector.PNG" alt="errorConnector.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do I need to implement something else for this to work?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 21:05:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/232748#M7334</guid>
      <dc:creator>eramirez</dc:creator>
      <dc:date>2017-08-16T21:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Data Connector Power BI, fill List with json response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/234080#M7372</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/39322"&gt;@eramirez&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Could you zip your project from visual studio and share it with me?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 10:07:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/234080#M7372</guid>
      <dc:creator>Eric_Zhang</dc:creator>
      <dc:date>2017-08-18T10:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Data Connector Power BI, fill List with json response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/234333#M7386</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6971"&gt;@Eric_Zhang&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/39322"&gt;@eramirez&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Could you zip your project from visual studio and share it with me?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi Eric, I just created a project in visual studio of type Data Connector Project and the only file that I got is the .pq file with this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// This file contains your Data Connector logic
section TestConnector;

[DataSource.Kind="TestConnector", Publish="TestConnector.Publish"]

shared TestConnector.Contents = Value.ReplaceType(TestConnectorImpl, TestConnectorType);

shared listTest = getDataFromUrl;

TestConnectorType = type function (
    count as (type text meta [
        Documentation.FieldCaption = "Count",
        Documentation.FieldDescription = "Number of times to repeat the message",
        Documentation.AllowedValues = listTest
    ]))
    as table meta [
        Documentation.Name = "Hello - Name",
        Documentation.LongDescription = "Hello - Long Description",
        Documentation.Examples = {[
            Description = "Another example, new message, new count!",
            Code = "HelloWorldWithDocs.Contents(""Goodbye"", 1)",
            Result = "#table({""Column1""}, {{""Goodbye""}})"
        ]}
    ];

    TestConnectorImpl = (count as number) as table =&amp;gt;
    let
        _count = count,
        listOfMessages = List.Repeat({_count},_count),
        table = Table.FromList(listOfMessages, Splitter.SplitByNothing())
    in
        table;

    getDataFromUrl = 
    let
        url = "http://localhost:8080/jsontest/",
        source = Web.Contents(url, [ Headers = DefaultRequestHeaders ]),
        xml = Xml.Tables(source),
        SessionState = Table.ExpandTableColumn(xml,"session-states",{"min-state"}),
        ss = Table.Column(SessionState,"min-state"),
        reportArray = Table.Column(SessionState,"report-array"),
        textJson =  Lines.ToText(reportArray),
        json = Json.Document(textJson),
        ids = Table.FromRecords(json,{"name"}),
        list = Table.ToList(ids),
        test = {1,2,3}
    in
        list;


// Data Source Kind description
TestConnector = [
    Authentication = [
        // Key = [],
        // UsernamePassword = [],
        // Windows = [],
        Implicit = []
    ],
    Label = "Test Connector"
];

// Data Source UI publishing description
TestConnector.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = TestConnector.Icons,
    SourceTypeImage = TestConnector.Icons
];

TestConnector.Icons = [
    Icon16 = { Extension.Contents("TestConnector16.png"), Extension.Contents("TestConnector20.png"), Extension.Contents("TestConnector24.png"), Extension.Contents("TestConnector32.png") },
    Icon32 = { Extension.Contents("TestConnector32.png"), Extension.Contents("TestConnector40.png"), Extension.Contents("TestConnector48.png"), Extension.Contents("TestConnector64.png") }
];

DefaultRequestHeaders = [
    #"Accept" = "application/json;odata.metadata=minimal",  // column name and values only
    #"OData-MaxVersion" = "4.0"                             // we only support v4
];&lt;/PRE&gt;&lt;P&gt;and in the url http://localhost:8080/jsontest/, I'm just creating a local service created in Java (just for testing because the remote url is also in development) that only returns this string as xml&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&amp;lt;taskResponse statusCode=\"200\"&amp;gt;&amp;lt;report-array&amp;gt;[{\"id\":\"1\",\"name\":\"1\"},{\"id\":\"2\",\"name\":\"2\"},{\"id\":\"3\",\"name\":\"3\"}]&amp;lt;/report-array&amp;gt;&amp;lt;session-states&amp;gt;&amp;lt;min-state&amp;gt;true&amp;lt;/min-state&amp;gt;&amp;lt;/session-states&amp;gt;&amp;lt;/taskResponse&amp;gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 16:45:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Power-BI-fill-List-with-json-response/m-p/234333#M7386</guid>
      <dc:creator>eramirez</dc:creator>
      <dc:date>2017-08-18T16:45:59Z</dc:date>
    </item>
  </channel>
</rss>

