Forum Discussion
Anonymous
6 years agoNot applicable
API with Template Parameter based on Freemarker
I need help converting a Rest API to be useable in Power Query. The issue I am having is with the --data-urlencode Template as I get a "Response Message: No Template Submitted". Code request is c...
v-lid-msft
6 years agoCommunity Support
Hi Anonymous ,
We can try to use the Uri.EscapeDataString function to encode the body request:
let
Description = "requestJobDescription={
""type"":""file"",
""credentials"":{
""partnerUserID"":""username"",
""partnerUserSecret"":""password""
},
""onReceive"":{
""immediateResponse"":[""returnRandomFileName""]
},
""inputSettings"":{
""type"":""combinedReportData"",
""reportState"":""APPROVED"",
""limit"":""10"",
""filters"":{
""startDate"":""2019-01-01"",
""endDate"":""2019-10-01""
}
},
""outputSettings"":{
""fileExtension"":""csv""
},
}",
BodyRequest = Uri.EscapeDataString("template=
<#if addHeader == true>
Merchant,Original Amount,Category,Report number,Expense number<#lt>
</#if>
<#assign reportNumber = 1>
<#assign expenseNumber = 1>
<#list reports as report>
<#list report.transactionList as expense>
${expense.merchant},<#t>
<#-- note: expense.amount prints the original amount only -->
${expense.amount},<#t>
${expense.category},<#t>
${reportNumber},<#t>
${expenseNumber}<#lt>
<#assign expenseNumber = expenseNumber + 1>
</#list>
<#assign reportNumber = reportNumber + 1>
</#list>
"
),
RelativePathString = "/Integration-Server/ExpensifyIntegrations",
URLRequest = "https://integrations.expensify.com",
Request = Csv.Document(Web.Contents(URLRequest, [RelativePath=RelativePathString, Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content = Text.ToBinary(Description & BodyRequest)]))
in
Request
Best regards,
Anonymous
6 years agoNot applicable
Thanks for the response v-lid-msft ,
Unfortunately it still results in the "Response Message: No Template Submitted". I have updated my Advanced Editor to be the text for reference as this progresses.
Any other ideas?
Seems silly that this template parameter is being such a pain!
- nutzschneider4 years agoNew Member
Hello,
I've been tackeling the exact same problem, any chance you eventually found a solution?
Thanks,