<?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: convert python code to M inside query in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483067#M35763</link>
    <description>&lt;P&gt;The process is the same as in my previous response, minus the payload. You switch between POST and GET by including a content option (or not).&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 11:25:48 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-04-28T11:25:48Z</dc:date>
    <item>
      <title>convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2471450#M35650</link>
      <description>&lt;P&gt;Hello everyone,&lt;BR /&gt;&lt;BR /&gt;would anyone be able to help me translate this code which is written in python to M language in power query.&lt;/P&gt;&lt;P&gt;I can't convert&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import http.client

conn = http.client.HTTPConnection("app.salsify.com")

payload = "{\n    \"configuration\": {\n        \"entity_type\": \"all\",\n        \"filter\": \"=list:default\",\n        \"properties\": \"'UPC','Product Name','Brand','Main Image','Short Description','Long Description'\",\n        \"include_all_columns\": false,\n        \"sort_order\": \"desc\",\n        \"sort_property\": \"Brand\"\n    }\n}"

headers = {
    'Content-Type': "application/json",
    'Authorization': "Bearer s-999-999-999-999",
    'User-Agent': "PostmanRuntime/7.19.0",
    'Accept': "*/*",
    'Cache-Control': "no-cache",
    'Host': "app.salsify.com",
    'Accept-Encoding': "gzip, deflate",
    'Content-Length': "304",
    'Cookie': "_cookie_id",
    'Connection': "keep-alive",
    'cache-control': "no-cache"
    }

conn.request("POST", "api,orgs,s-999-999-999-999,export_runs", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

# where org_id = s-999-999-999-999, api_token = YOUR-AUTH-TOKEN, and cookie id = _cookie_id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 11:59:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2471450#M35650</guid>
      <dc:creator>EDO_01_1789</dc:creator>
      <dc:date>2022-04-22T11:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2472964#M35659</link>
      <description>&lt;P&gt;You use the regular Web.Contents() call and specify the payload in the Content&amp;nbsp; section.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    url = "https://app.salsify.com",
    payload = "{\""configuration\"": {\""entity_type\"": \""all\"",\""filter\"": \""=list:default\"",\""properties\"": \""'UPC','Product Name','Brand','Main Image','Short Description','Long Description'\"",\""include_all_columns\"": false,\""sort_order\"": \""desc\"",\""sort_property\"": \""Brand\""}}",
    Source = Web.Contents(url,[Headers=[#"Content-Type"= "application/json",Authorization = "Bearer s-999-999-999-999"],Content=Text.ToBinary(payload)])
in
    Source&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without access to the API that's all the help we can provide.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2022 23:29:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2472964#M35659</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-04-23T23:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2482470#M35755</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100342"&gt;@lbendlin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;sorry for taking time to answer you.&lt;BR /&gt;I share with you below the link of the site which gives you more information about the API. &lt;A href="https://developers.salsify.com/reference/get-export-status" target="_blank"&gt;https://developers.salsify.com/reference/get-export-status&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I've been trying to connect to the site for more than a week.&lt;/P&gt;&lt;P&gt;The site tells me to use&lt;BR /&gt;org_id : in our example we will use ABCDE&lt;BR /&gt;export_id : in our example we will use XYZ&lt;/P&gt;&lt;P&gt;here is the code that the site generates for me in python and I would like to transform it into M language in the query.&lt;/P&gt;&lt;P&gt;is this possible ?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import http.client

conn = http.client.HTTPConnection("app.salsify.com")

payload = ""

headers = {
    'Content-Type': "application/json",
    'Authorization': "Bearer YOUR-AUTH-TOKEN",
    'User-Agent': "PostmanRuntime/7.19.0",
    'Accept': "*/*",
    'Cache-Control': "no-cache",
    'Host': "app.salsify.com",
    'Accept-Encoding': "gzip, deflate",
    'Cookie': "_cookie_id",
    'Connection': "keep-alive",
    'cache-control': "no-cache"
    }

conn.request("GET", "api,orgs,s-999-999-999-999,export_runs,19350473", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

# where export_id = 19350473 org_id = s-999-999-999-999, api_token = YOUR-AUTH-TOKEN, cookie id = _cookie_id&lt;/LI-CODE&gt;&lt;P&gt;thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 08:12:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2482470#M35755</guid>
      <dc:creator>EDO_01_1789</dc:creator>
      <dc:date>2022-04-28T08:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483067#M35763</link>
      <description>&lt;P&gt;The process is the same as in my previous response, minus the payload. You switch between POST and GET by including a content option (or not).&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 11:25:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483067#M35763</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-04-28T11:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483160#M35764</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/100342"&gt;@lbendlin&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried this code and it doesn't work&lt;BR /&gt;here is my error message&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EDO_01_1789_0-1651146751794.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/706494iAA38710AF40FFD96/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EDO_01_1789_0-1651146751794.png" alt="EDO_01_1789_0-1651146751794.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the code I pasted in the query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    url = "https://app.salsify.com",
    payload = "{\""configuration\"": {\""entity_type\"": \""all\"",\""filter\"": \""=list:default\"",\""properties\"": \""'UPC','Product Name','Brand','Main Image','Short Description','Long Description'\"",\""include_all_columns\"": false,\""sort_order\"": \""desc\"",\""sort_property\"": \""Brand\""}}",
    Source = Web.Contents(url, [Headers=[#"Content-Type"="application/json", Authorization="abcde"]])
in
    Source&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 11:53:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483160#M35764</guid>
      <dc:creator>EDO_01_1789</dc:creator>
      <dc:date>2022-04-28T11:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483370#M35766</link>
      <description>&lt;P&gt;The message is clear on what you need to do.&amp;nbsp; Easiest will be to go to data source settings, remove the API source, and then refresh, specifying anonymous auth.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;your "authorization"&amp;nbsp; header must have the format "Bearer abcde" , not just "abcde" .&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 13:12:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483370#M35766</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-04-28T13:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483541#M35770</link>
      <description>&lt;P&gt;it's starting to work, but do you know why I don't have any data?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EDO_01_1789_0-1651154855964.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/706581i8E3E8A4720C0331B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EDO_01_1789_0-1651154855964.png" alt="EDO_01_1789_0-1651154855964.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:07:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483541#M35770</guid>
      <dc:creator>EDO_01_1789</dc:creator>
      <dc:date>2022-04-28T14:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483580#M35771</link>
      <description>&lt;P&gt;Your API call needs to be modified according to their documentation and based on what you are trying to accomplish.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 14:26:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2483580#M35771</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-04-28T14:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert python code to M inside query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2512812#M36087</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/381709"&gt;@EDO_01_1789&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Any update on this? Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If these also don't help, please share more detailed information to help us clarify your scenario to test.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 08:42:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/convert-python-code-to-M-inside-query/m-p/2512812#M36087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-13T08:42:52Z</dc:date>
    </item>
  </channel>
</rss>

