<?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 Re: Writing JSON/List into Lakehouse's Files in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797668#M11757</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1319156" data-lia-user-login="dolphinantonym" class="lia-mention lia-mention-user"&gt;dolphinantonym&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;open() can’t write to an abfss://… URL. In Fabric notebooks, either use the Lakehouse File API path that’s mounted into the notebook, or use NotebookUtils (mssparkutils) to write to OneLake.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Option 1 &amp;gt;&lt;STRONG&gt; Use the mounted Lakehouse path (works with plain Python)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Make sure your target Lakehouse is attached as Default (pin icon). Then write to the File API path:&lt;/P&gt;&lt;P&gt;import json, os&lt;/P&gt;&lt;P&gt;out_path = "/lakehouse/default/Files/APIResponse.json" # File API path&lt;BR /&gt;os.makedirs("/lakehouse/default/Files", exist_ok=True)&lt;/P&gt;&lt;P&gt;with open(out_path, "w", encoding="utf-8") as f:&lt;BR /&gt;json.dump(AllResults, f, ensure_ascii=False, indent=2)&lt;/P&gt;&lt;P&gt;print("Wrote:", out_path)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Refresh the Files pane and you should see APIResponse.json. (The default Lakehouse mount point is /lakehouse/default. If you only provide a relative path like Files/..., Fabric will also resolve it to the default Lakehouse.)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Option 2&amp;gt;&lt;STRONG&gt; Use NotebookUtils (mssparkutils)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is a one-liner that writes text content into OneLake:&lt;/P&gt;&lt;P&gt;from notebookutils import mssparkutils&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;mssparkutils.fs.put("Files/APIResponse.json",&lt;BR /&gt;json.dumps(AllResults, ensure_ascii=False, indent=2),&lt;BR /&gt;True) # overwrite=True&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can verify with:&lt;/P&gt;&lt;P&gt;mssparkutils.fs.ls("Files")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Docs for fs.put/fs.ls here.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Why your original code didn’t show a file&lt;/STRONG&gt;&lt;BR /&gt;open("abfss://…", "w") doesn’t target OneLake; Python’s open() doesn’t understand the ABFSS scheme. Use the mounted File API path (/lakehouse/default/...) or mssparkutils instead.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If your end goal is to query the API data later, consider landing it as a Delta table (instead of a raw JSON file):&lt;/P&gt;&lt;P&gt;df = spark.createDataFrame(AllResults) # list[dict]&lt;BR /&gt;df.write.format("delta").mode("append").save("Tables/APIResponse")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;That creates/updates a managed Delta table under Tables, which you can query from the SQL endpoint.&lt;BR /&gt;Microsoft Learn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this helps, please &lt;STRONG&gt;mark it as Solution&lt;/STRONG&gt; and &lt;STRONG&gt;give it a kudos&lt;/STRONG&gt; so others can find it too. &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Aug 2025 04:51:35 GMT</pubDate>
    <dc:creator>Aala_Ali</dc:creator>
    <dc:date>2025-08-15T04:51:35Z</dc:date>
    <item>
      <title>Writing JSON/List into Lakehouse's Files</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797317#M11753</link>
      <description>&lt;P&gt;I am collecting a list - AllResults - from a REST API, and trying to store it as a JSON file in my Lakehouse. I can't work out where I'm going wrong - the following command doesn't error, but I don't see anything appear when I refresh the files in my Lakehouse:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FilePath = "abfss://MyWorkSpace@onelake.dfs.fabric.microsoft.com/MyLakehouse.Lakehouse/Files/APIResponse.json"

with open(FilePath, "w", encoding="utf-8") as f:
    json.dump(AllResults, f, indent=2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Aug 2025 16:53:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797317#M11753</guid>
      <dc:creator>dolphinantonym</dc:creator>
      <dc:date>2025-08-14T16:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Writing JSON/List into Lakehouse's Files</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797668#M11757</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1319156" data-lia-user-login="dolphinantonym" class="lia-mention lia-mention-user"&gt;dolphinantonym&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;open() can’t write to an abfss://… URL. In Fabric notebooks, either use the Lakehouse File API path that’s mounted into the notebook, or use NotebookUtils (mssparkutils) to write to OneLake.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Option 1 &amp;gt;&lt;STRONG&gt; Use the mounted Lakehouse path (works with plain Python)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Make sure your target Lakehouse is attached as Default (pin icon). Then write to the File API path:&lt;/P&gt;&lt;P&gt;import json, os&lt;/P&gt;&lt;P&gt;out_path = "/lakehouse/default/Files/APIResponse.json" # File API path&lt;BR /&gt;os.makedirs("/lakehouse/default/Files", exist_ok=True)&lt;/P&gt;&lt;P&gt;with open(out_path, "w", encoding="utf-8") as f:&lt;BR /&gt;json.dump(AllResults, f, ensure_ascii=False, indent=2)&lt;/P&gt;&lt;P&gt;print("Wrote:", out_path)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Refresh the Files pane and you should see APIResponse.json. (The default Lakehouse mount point is /lakehouse/default. If you only provide a relative path like Files/..., Fabric will also resolve it to the default Lakehouse.)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Option 2&amp;gt;&lt;STRONG&gt; Use NotebookUtils (mssparkutils)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is a one-liner that writes text content into OneLake:&lt;/P&gt;&lt;P&gt;from notebookutils import mssparkutils&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;mssparkutils.fs.put("Files/APIResponse.json",&lt;BR /&gt;json.dumps(AllResults, ensure_ascii=False, indent=2),&lt;BR /&gt;True) # overwrite=True&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can verify with:&lt;/P&gt;&lt;P&gt;mssparkutils.fs.ls("Files")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Docs for fs.put/fs.ls here.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Why your original code didn’t show a file&lt;/STRONG&gt;&lt;BR /&gt;open("abfss://…", "w") doesn’t target OneLake; Python’s open() doesn’t understand the ABFSS scheme. Use the mounted File API path (/lakehouse/default/...) or mssparkutils instead.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If your end goal is to query the API data later, consider landing it as a Delta table (instead of a raw JSON file):&lt;/P&gt;&lt;P&gt;df = spark.createDataFrame(AllResults) # list[dict]&lt;BR /&gt;df.write.format("delta").mode("append").save("Tables/APIResponse")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;That creates/updates a managed Delta table under Tables, which you can query from the SQL endpoint.&lt;BR /&gt;Microsoft Learn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this helps, please &lt;STRONG&gt;mark it as Solution&lt;/STRONG&gt; and &lt;STRONG&gt;give it a kudos&lt;/STRONG&gt; so others can find it too. &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 04:51:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797668#M11757</guid>
      <dc:creator>Aala_Ali</dc:creator>
      <dc:date>2025-08-15T04:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Writing JSON/List into Lakehouse's Files</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797766#M11759</link>
      <description>&lt;P&gt;EDIT: I have got this working using your suggested Option2, but modifying for a plain Python Notebook, by using &lt;STRONG&gt;notebookutils.fs.put()&lt;/STRONG&gt; rather than mssparkutils.fs.put() - thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Plain Python is the approach I prefer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you aware of ways to update the mounted/pinned Lakehouse in a CICD environment? In plain Python I am able to dynamically construct the&amp;nbsp;abfss://... path so I can do things like use write_delta() and have it write to Tables in a branch's Workspace without needing to manually change which Lakehouse is pinned in the branch, and again when I merge the Notebook back into my main branch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not aware of an equivalent to the&amp;nbsp;parameter.yml file that works within Workspaces that have been branched out to via Fabric's source control, because there is a new Workspace per branch rather than a permanent Workspace with a known ID for deployed code.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 08:39:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Writing-JSON-List-into-Lakehouse-s-Files/m-p/4797766#M11759</guid>
      <dc:creator>dolphinantonym</dc:creator>
      <dc:date>2025-08-15T08:39:23Z</dc:date>
    </item>
  </channel>
</rss>

