<?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: Problem with creating datasource under gateway through API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/418449#M12455</link>
    <description>&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;thank for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this manual,&lt;/P&gt;&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt784643.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/mt784643.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it should be possible to create a new datasource under&amp;nbsp;gateway.&lt;/P&gt;</description>
    <pubDate>Wed, 16 May 2018 09:06:12 GMT</pubDate>
    <dc:creator>nikolasNovak</dc:creator>
    <dc:date>2018-05-16T09:06:12Z</dc:date>
    <item>
      <title>Problem with creating datasource under gateway through API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/414814#M12354</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I am trying to create new datasources under gateway using api from C# but still gets error response "400: Bad request".&lt;BR /&gt;&lt;BR /&gt;Supplied&amp;nbsp;credentials encrypted as described in&amp;nbsp;&lt;A href="https://msdn.microsoft.com/en-us/library/mt784645.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/mt784645.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's code i'm using...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; string powerBIDatasourcesApiUrl = String.Format("https://api.powerbi.com/v1.0/myorg/gateways/{0}/datasources", gatewayId); &lt;BR /&gt; HttpWebRequest request = System.Net.WebRequest.Create(powerBIDatasourcesApiUrl) as System.Net.HttpWebRequest;&lt;BR /&gt; //POST web request to create a datasource.&lt;BR /&gt; request.KeepAlive = true;&lt;BR /&gt; request.Method = "POST";&lt;BR /&gt; request.ContentLength = 0;&lt;BR /&gt; request.ContentType = "application/json";&lt;BR /&gt;&lt;BR /&gt; //Add token to the request header&lt;BR /&gt; request.Headers.Add("Authorization", String.Format("Bearer {0}", token));&lt;BR /&gt;&lt;BR /&gt;string datasourceJson =
                "{" +
                    "\"name\":\"" + &amp;lt;datasourceName&amp;gt; + "\"," +
                    "\"type\":\"Sql\"," +
                    "\"connectionDetails\":\"{\"server\":\"&amp;lt;server&amp;gt;\",\"database\":\"&amp;lt;database&amp;gt;\"}\"," +
                    "\"credentialDetails\":{" +
                        "\"credentials\":\"" + &amp;lt;credentialsHash&amp;gt; + "\"," +
                        "\"encryptionAlgorithm\":\"RSA-OAEP\"," +
                        "\"encryptedConnection\":\"Encrypted\"," +
                        "\"privacyLevel\":\"Public\"," +
                        "\"credentialType\":\"Windows\"" +
                    "}}";&lt;BR /&gt;//POST web request&lt;BR /&gt; byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(datasourceJson);&lt;BR /&gt; request.ContentLength = byteArray.Length;&lt;BR /&gt;&lt;BR /&gt; //Write JSON byte[] into a Stream&lt;BR /&gt; using (Stream writer = request.GetRequestStream())&lt;BR /&gt; {&lt;BR /&gt; writer.Write(byteArray, 0, byteArray.Length);&lt;BR /&gt; writer.Flush();&lt;BR /&gt; writer.Close();&lt;BR /&gt; writer.Dispose();&lt;BR /&gt;&lt;BR /&gt; var response = (HttpWebResponse)request.GetResponse();&lt;BR /&gt;&lt;BR /&gt; Console.WriteLine(string.Format("Datasource {0}", response.StatusCode.ToString()));&lt;BR /&gt; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:59:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/414814#M12354</guid>
      <dc:creator>nikolasNovak</dc:creator>
      <dc:date>2018-05-10T14:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating datasource under gateway through API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/415832#M12383</link>
      <description>&lt;P&gt;You can't add a new datasource through the patch Datasource API, as this API is used to:&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;updates the credentials for a data source&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As far as I know, currently there is no possible way to create new datasource, what could be done is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Update the existing DataSource connection string, or update the credentials for a data source.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://msdn.microsoft.com/en-US/library/mt771178.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-US/library/mt771178.aspx&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Michael&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 06:58:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/415832#M12383</guid>
      <dc:creator>v-micsh-msft</dc:creator>
      <dc:date>2018-05-12T06:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with creating datasource under gateway through API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/418449#M12455</link>
      <description>&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;thank for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this manual,&lt;/P&gt;&lt;P&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt784643.aspx" target="_blank"&gt;https://msdn.microsoft.com/en-us/library/mt784643.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;it should be possible to create a new datasource under&amp;nbsp;gateway.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 09:06:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problem-with-creating-datasource-under-gateway-through-API/m-p/418449#M12455</guid>
      <dc:creator>nikolasNovak</dc:creator>
      <dc:date>2018-05-16T09:06:12Z</dc:date>
    </item>
  </channel>
</rss>

