Forum Discussion
convert python code to M inside query
- Anonymous4 years ago
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
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.
- EDO_01_17894 years agoHelper I
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-statusI'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 XYZhere 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
- lbendlin4 years agoSuper User
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).