Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello everyone,
would anyone be able to help me translate this code which is written in python to M language in power query.
I can't convert
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
thank you for your help.
Solved! Go to Solution.
Hi @EDO_01_1789,
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.
If these also don't help, please share more detailed information to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Hi @EDO_01_1789,
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.
If these also don't help, please share more detailed information to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
I just tried this code and it doesn't work
here is my error message
here is the code I pasted in the query
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
The message is clear on what you need to do. Easiest will be to go to data source settings, remove the API source, and then refresh, specifying anonymous auth.
your "authorization" header must have the format "Bearer abcde" , not just "abcde" .
it's starting to work, but do you know why I don't have any data?
Your API call needs to be modified according to their documentation and based on what you are trying to accomplish.
You use the regular Web.Contents() call and specify the payload in the Content section.
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
Without access to the API that's all the help we can provide.
Hello @lbendlin
sorry for taking time to answer you.
I share with you below the link of the site which gives you more information about the API. https://developers.salsify.com/reference/get-export-status
I've been trying to connect to the site for more than a week.
The site tells me to use
org_id : in our example we will use ABCDE
export_id : in our example we will use XYZ
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.
is this possible ?
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_idthanks for your help
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).
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |