<?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: Pagination results in poorly-formed JSON in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4627304#M7348</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="723064" data-lia-user-login="menchgelof" class="lia-mention lia-mention-user"&gt;menchgelof&lt;/a&gt;&amp;nbsp;, thanks for your quick answer and suggestions!&lt;/P&gt;&lt;P&gt;I've also tried a little bit with available options and turned out that setting up&amp;nbsp;&lt;EM&gt;File pattern&amp;nbsp;&lt;/EM&gt;help to provide correct JSON format&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;. Weird as I' pretty sure I've tested this option too before and it didn't work.&lt;/P&gt;&lt;P&gt;Nevertheless, seems our problem is resolved in here. You can also try this out in case You would like to use &lt;EM&gt;Copy Activity&lt;/EM&gt; instead of &lt;EM&gt;Notebooks&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Mar 2025 10:47:56 GMT</pubDate>
    <dc:creator>kubas</dc:creator>
    <dc:date>2025-03-27T10:47:56Z</dc:date>
    <item>
      <title>Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4047180#M4619</link>
      <description>&lt;P&gt;I have configured a Copy Activity to call paginated results from a REST API. The pagination rules work, calling all pages and assembling them into a single JSON file. However, the output file is poorly-formed JSON. Each page is appended as a list object in the final output file without a comma between them, and there is no set of brackets wrapped around all the page objects, leaving many objects at the root level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output file looks like this:&lt;/P&gt;&lt;PRE&gt;{"page 1 content"}&lt;BR /&gt;{"page 2 content"}&lt;BR /&gt;{"page 3 content"}&lt;BR /&gt;…&lt;/PRE&gt;&lt;P&gt;I've tried setting the Destination &lt;STRONG&gt;Copy behavior&lt;/STRONG&gt;&amp;nbsp;to "Merge files," "Flatten hierarchy," and "Preserve hierarchy." I've also tried changing the &lt;STRONG&gt;File pattern&amp;nbsp;&lt;/STRONG&gt;setting to "Array of objects" and "Set of objects." All combinations of settings produce identical files; the settings seem to have no change on the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone experienced this? I'm bewildered on how pagination returns poorly-formed JSON format or what to do about it.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 01:58:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4047180#M4619</guid>
      <dc:creator>menchgelof</dc:creator>
      <dc:date>2024-07-18T01:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4048241#M4624</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="723064" data-lia-user-login="menchgelof" class="lia-mention lia-mention-user"&gt;menchgelof&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try to reproduce your needs and try to give a solution. Please be patient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Adamk Kong&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 10:11:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4048241#M4624</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-18T10:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4057063#M4678</link>
      <description>&lt;P&gt;I spent some time with&amp;nbsp;Microsoft Fabric Support today, and we discovered that the preview of the incoming API data (from either the Source or Destination settings) shows proper JSON—meaning that the pages are assembled correctly. They are separated by a comma, and the whole document is wrapped in brackets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see the separation commas in the included screenshot. However, the eventual file output lacks these commas (and document-wrapping brackets). I'm beginning to think this is a bug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 17:27:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4057063#M4678</guid>
      <dc:creator>menchgelof</dc:creator>
      <dc:date>2024-07-23T17:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4625900#M7341</link>
      <description>&lt;P&gt;Any updates on that, please? We are also facing the same issue&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 13:03:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4625900#M7341</guid>
      <dc:creator>kubas</dc:creator>
      <dc:date>2025-03-26T13:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4626310#M7344</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1246146" data-lia-user-login="kubas" class="lia-mention lia-mention-user"&gt;kubas&lt;/a&gt;, I gave up on waiting for a fix and moved to using Notebooks to handle paginated API data with a simple if-else loop. Obviously, that's not a solution to the pipeline itself, but it's a way to handle paginated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this custom function to assemble the pages and save it all as a variable:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def fetch_paginated_data(base_api_url, endpoint_url, headers, params):
    api_url = base_api_url + endpoint_url  # Concatenate base and endpoint URLs
    all_data = []
    while api_url:
        response = requests.get(api_url, headers=headers, params=params)
        
        if response.status_code == 200:
            data = response.json()
            all_data.extend(data.get('objects', []))  # Collect only the objects
            next_url = data.get('meta', {}).get('next')
            if next_url:
                api_url = base_api_url + next_url  # Construct the full URL for the next page
                params = None  # Reset params after the first request
            else:
                api_url = None
        else:
            print(f"Failed to get data from API. Status code: {response.status_code}")
            break
    return all_data&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I then had to handle formatting the assembled JSON data into well-formed JSON with this bit:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Convert the collected data to a JSON string
json_data = json.dumps(all_data, separators=(',', ':'))&lt;/LI-CODE&gt;&lt;P&gt;I then save the JSON data to a file I can save in my lakehouse and use however I need.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 17:33:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4626310#M7344</guid>
      <dc:creator>menchgelof</dc:creator>
      <dc:date>2025-03-26T17:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4627304#M7348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="723064" data-lia-user-login="menchgelof" class="lia-mention lia-mention-user"&gt;menchgelof&lt;/a&gt;&amp;nbsp;, thanks for your quick answer and suggestions!&lt;/P&gt;&lt;P&gt;I've also tried a little bit with available options and turned out that setting up&amp;nbsp;&lt;EM&gt;File pattern&amp;nbsp;&lt;/EM&gt;help to provide correct JSON format&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;. Weird as I' pretty sure I've tested this option too before and it didn't work.&lt;/P&gt;&lt;P&gt;Nevertheless, seems our problem is resolved in here. You can also try this out in case You would like to use &lt;EM&gt;Copy Activity&lt;/EM&gt; instead of &lt;EM&gt;Notebooks&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 10:47:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4627304#M7348</guid>
      <dc:creator>kubas</dc:creator>
      <dc:date>2025-03-27T10:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Pagination results in poorly-formed JSON</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4627677#M7351</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1246146" data-lia-user-login="kubas" class="lia-mention lia-mention-user"&gt;kubas&lt;/a&gt;,&amp;nbsp;I believe I had also tried changing the setting for how to structure the JSON without success. Perhaps Microsoft did make a change.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 13:26:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Pagination-results-in-poorly-formed-JSON/m-p/4627677#M7351</guid>
      <dc:creator>menchgelof</dc:creator>
      <dc:date>2025-03-27T13:26:47Z</dc:date>
    </item>
  </channel>
</rss>

