Azure Data Factory: Copy activity to save Json from Rest API as CSV/Parquet to ADLS Gen2

Leela Yarlagadda 26 Reputation points
2022-04-01T18:00:22.373+00:00

Trying to save Json output from Rest API as CSV/Parquet file to ADLS Gen2 using Copy activity.

Successful connection to Rest API and can Preview data in Source tab on Copy activity.

Object:
[
{
"Assets": [
{
"ActivationStatus": 0,
"AssetDescription": null,
"AssetId": 2517322
} ,
...
],
"TotalCount": 3436
}
]

But no data is being saved to CSV, the file is empty.
Would like to get the schema automatically to target, but tried manual mapping as well to see if data can be saved. But no luck.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

Accepted answer
  1. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2022-04-04T22:57:57.21+00:00

    Hello @Leela Yarlagadda ,

    Thanks for the question and using MS Q&A platform.

    As per my understanding you are trying to save the API response (JSON) to a CSV/Parquet file in your ADLS Gen2 using ADF copy activity, but you are seeing an empty file generated. Please correct if my understanding is incorrect.

    I just tried with a free API to test it out noticed the same behavior as yours at first go, then under mapping section of copy, I tried to import schemas and then specified the JSONPath of the nested JSON array for cross-apply (nothing but selecting the Collection Reference) and then for all the null types in source columns, select schema type as string for corresponding sink columns and the data copy was successful. And I can then see the data available in CSV file.

    Here is the API I tried to reproduce the problem:

    Below is my source structure which is pretty much similar to your source schema structure. Here is the sample data: 189886-apiresponsejsonarray.txt

    189915-image.png

    Below are the mapping settings I have configured to avoid mapping issues because of null data types from source.

    189951-image.png

    Here is the sample output copied to my sink file:

    189916-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.