Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cleon169
Frequent Visitor

Advanced Editor - defined variable inside Text.ToBinary

I'm rather new to M code. I'm trying to get the current date as a variable to appear inside this XML API call that is wrapped up in a Text.ToBinary function. Any suggestions?

 

let

defined = DateTime.ToText(DateTime.LocalNow()),

Source = Xml.Tables(Web.Contents("https:...ReportingWs.asmx?WSDL"

,[Content=Text.ToBinary("<soapenv:Envelope xmlns:soapenv="&Character.FromNumber(34)&"http://schemas.xmlsoap.org/soap/envelope/"&Character.FromNumber(34)&" xmlns:rep="&Character.FromNumber(34)&"http://...ReportingWs"&Character.FromNumber(34)&">
<soapenv:Header/>
<soapenv:Body>
<rep:ConsolidatedReport>
<rep:sLocationCodesCommaDelimited>L001,L002</rep:sLocationCodesCommaDelimited>
<rep:sCorpUserName>...</rep:sCorpUserName>
<rep:sCorpPassword>...</rep:sCorpPassword>
<rep:dReportDateStart>2018-04-01T00:00:00</rep:dReportDateStart>
<rep:dReportDateEnd>defined</rep:dReportDateEnd>
</rep:ConsolidatedReport>
</soapenv:Body>
</soapenv:Envelope>"),Headers=[#"Accept-Encoding"="gzip,deflate", #"Content-Type"="text/xml;charset=UTF-8"]]))
in
Source

1 ACCEPTED SOLUTION
ThisIsFalse
Resolver I
Resolver I

I am not familliar with that function but it seems that you have done a simmilar thing already in the fucntion. Have you tried the same technique you used earlier? ("&Character.FromNumber(34)&") 

That is instead of 

<rep:dReportDateEnd>defined</rep:dReportDateEnd>

<rep:dReportDateEnd>" & defined & "</rep:dReportDateEnd>? 

View solution in original post

3 REPLIES 3
ThisIsFalse
Resolver I
Resolver I

I am not familliar with that function but it seems that you have done a simmilar thing already in the fucntion. Have you tried the same technique you used earlier? ("&Character.FromNumber(34)&") 

That is instead of 

<rep:dReportDateEnd>defined</rep:dReportDateEnd>

<rep:dReportDateEnd>" & defined & "</rep:dReportDateEnd>? 

Thanks ThisIsFalse. I had been trying to use "Character.FromNumber(34)&"Defined"&Character.FromNumber(34)" as I incorrectly thought it needed to be in double quotes. I also had the date variable formatted differently than the API required. Here's the line I used:

 

         <rep:dReportDateEnd>"&Defined&"</rep:dReportDateEnd>

Well  I am glad you got it sorted out. I felt that it was a little too simple the way you presented it, formatting is always an issue with this kind of thing.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.