<?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 Use another query result as text parameter in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Use-another-query-result-as-text-parameter/m-p/643815#M18790</link>
    <description>&lt;P&gt;I need to pass a json document as body to another Graph API query.&lt;/P&gt;&lt;P&gt;The source where I want to get the parameter data is:&lt;/P&gt;&lt;PRE&gt;rooms = Json.Document(Web.Contents("https://graph.microsoft.com/beta/me/findRooms",[ Headers = [#"Content-Type"="application/json"] ] ))&lt;/PRE&gt;&lt;P&gt;The source data that comes from Graph API like:&lt;/P&gt;&lt;PRE&gt;{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.emailAddress)",
  "value": [
    {
      "name": "Room1",
      "address": "Room1@my.com"
    },
    {
      "name": "Room2",
      "address": "Room2@my.com"
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;The desired result is the following JSON is. What I want from another query is the first, "schedules" part:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
"schedules": [
"room1@my.com",
"room1@my.com"
],
"startTime": {
"dateTime": "2019-03-01T09:00:00",
"timeZone": "Central European Time"
},
"endTime": {
"dateTime": "2019-04-01T09:00:00",
"timeZone": "Central European Time"
},
"availabilityViewInterval": "15"
}&lt;/PRE&gt;&lt;P&gt;I can extract the column I need:&lt;/P&gt;&lt;PRE&gt;  let
    rooms = Json.Document(Web.Contents(roomsurl,[ Headers = [#"Content-Type"="application/json"] ] )),
    roomsvalue = rooms[value],
    #"roomstable" = Table.FromList(roomsvalue, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"roomaddress" = Table.ExpandRecordColumn(#"roomstable", "Column1", {"address"}, {"schedules"})
  in
    #"roomaddress"&lt;/PRE&gt;&lt;P&gt;But I couldn't find how can I convert this list back to a json text. If I try this:&lt;/P&gt;&lt;PRE&gt;    jsaddress = Json.FromValue(#"roomaddress"),
    tx = Binary.ToText(jsaddress)&lt;/PRE&gt;&lt;P&gt;, that returns a binary object as text, not the json text. Can somebody please help me out?&lt;/P&gt;&lt;P&gt;Finally, I need to put this JSON text in the following query in place of "params"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;schedules = Json.Document(Web.Contents("https://graph.microsoft.com/beta/me/calendar/getschedule",[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(params) ] ))&lt;/PRE&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2019 09:28:11 GMT</pubDate>
    <dc:creator>vilmarci</dc:creator>
    <dc:date>2019-03-13T09:28:11Z</dc:date>
    <item>
      <title>Use another query result as text parameter</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Use-another-query-result-as-text-parameter/m-p/643815#M18790</link>
      <description>&lt;P&gt;I need to pass a json document as body to another Graph API query.&lt;/P&gt;&lt;P&gt;The source where I want to get the parameter data is:&lt;/P&gt;&lt;PRE&gt;rooms = Json.Document(Web.Contents("https://graph.microsoft.com/beta/me/findRooms",[ Headers = [#"Content-Type"="application/json"] ] ))&lt;/PRE&gt;&lt;P&gt;The source data that comes from Graph API like:&lt;/P&gt;&lt;PRE&gt;{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.emailAddress)",
  "value": [
    {
      "name": "Room1",
      "address": "Room1@my.com"
    },
    {
      "name": "Room2",
      "address": "Room2@my.com"
    }
  ]
}&lt;/PRE&gt;&lt;P&gt;The desired result is the following JSON is. What I want from another query is the first, "schedules" part:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
"schedules": [
"room1@my.com",
"room1@my.com"
],
"startTime": {
"dateTime": "2019-03-01T09:00:00",
"timeZone": "Central European Time"
},
"endTime": {
"dateTime": "2019-04-01T09:00:00",
"timeZone": "Central European Time"
},
"availabilityViewInterval": "15"
}&lt;/PRE&gt;&lt;P&gt;I can extract the column I need:&lt;/P&gt;&lt;PRE&gt;  let
    rooms = Json.Document(Web.Contents(roomsurl,[ Headers = [#"Content-Type"="application/json"] ] )),
    roomsvalue = rooms[value],
    #"roomstable" = Table.FromList(roomsvalue, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"roomaddress" = Table.ExpandRecordColumn(#"roomstable", "Column1", {"address"}, {"schedules"})
  in
    #"roomaddress"&lt;/PRE&gt;&lt;P&gt;But I couldn't find how can I convert this list back to a json text. If I try this:&lt;/P&gt;&lt;PRE&gt;    jsaddress = Json.FromValue(#"roomaddress"),
    tx = Binary.ToText(jsaddress)&lt;/PRE&gt;&lt;P&gt;, that returns a binary object as text, not the json text. Can somebody please help me out?&lt;/P&gt;&lt;P&gt;Finally, I need to put this JSON text in the following query in place of "params"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;schedules = Json.Document(Web.Contents("https://graph.microsoft.com/beta/me/calendar/getschedule",[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(params) ] ))&lt;/PRE&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 09:28:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Use-another-query-result-as-text-parameter/m-p/643815#M18790</guid>
      <dc:creator>vilmarci</dc:creator>
      <dc:date>2019-03-13T09:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Use another query result as text parameter</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Use-another-query-result-as-text-parameter/m-p/879228#M21773</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/115852"&gt;@vilmarci&lt;/a&gt;&amp;nbsp;, if you want the output to be the text representation of a JSON document; have you tried to use the Text.FromBinary function? Try to edit the query to the following:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;jsaddress = Json.FromValue(#"roomaddress"),
tx = Text.FromBinary(
           Json.FromValue(jsaddress)
     )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/powerquery-m/json-fromvalue" target="_self"&gt;Example of Text.FromBinary in use on JSON formatted data in the docs&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 18:59:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Use-another-query-result-as-text-parameter/m-p/879228#M21773</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-18T18:59:21Z</dc:date>
    </item>
  </channel>
</rss>

