Copy activity with REST source - mapping JSON to SQL

Paul Hernandez 691 Reputation points Microsoft Employee
2022-02-08T17:29:10.093+00:00

Hi everyone,

I'm trying to parse a response from a REST call using the copy activity.

I can check how the response looks like using the preview data:

172323-image.png

I used the "import schema" option in the copy activity. The mappings look like:

172225-image.png

The pipeline finished successfully but no record is inserted in the target table.

I also verified the json path in the "Advanced editor" and check them with an online jsonpath evaluator:

172314-image.png

Everything looks good to me. The only strange thing is, in the data preview an extra array level is shown on the top level, but I guess this is only a data preview thing.

Any help will be highly appreciated.

Best regards,

Paul

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,161 Reputation points
    2022-02-17T17:40:15.41+00:00

    Sorry for the delay. I have the results of my next test. @Paul Hernandez @Ryan Abbey

    Again shortcutting by using JSOn in a blob instead of REST connector, but this time with SQL sink, I was able to successfuly copy all. This indicates the cause is not due to being SQL. That leaves the possibility of the cause being a REST source with pagination mixing with the mapping collection reference. Or a typo in mapping.

    175478-image.png

    Source data:

    {  
    	"lowdata":"hello",  
    	"value": [  
    		{  
    			"id": "02",  
    			"displayName": "deus"  
    		},  
    		{  
    			"id": "04",  
    			"displayName": "quat"  
    		},  
    		{  
    			"id": "08",  
    			"displayName": "oct"  
    		}  
    	]  
    }  
    

    Pipeline definition:

    {  
        "name": "pipeline21",  
        "properties": {  
            "activities": [  
                {  
                    "name": "Copy data1",  
                    "type": "Copy",  
                    "dependsOn": [],  
                    "policy": {  
                        "timeout": "7.00:00:00",  
                        "retry": 0,  
                        "retryIntervalInSeconds": 30,  
                        "secureOutput": false,  
                        "secureInput": false  
                    },  
                    "userProperties": [],  
                    "typeProperties": {  
                        "source": {  
                            "type": "JsonSource",  
                            "additionalColumns": [  
                                {  
                                    "name": "time",  
                                    "value": {  
                                        "value": "@utcnow()",  
                                        "type": "Expression"  
                                    }  
                                }  
                            ],  
                            "storeSettings": {  
                                "type": "AzureBlobStorageReadSettings",  
                                "recursive": false,  
                                "enablePartitionDiscovery": false  
                            },  
                            "formatSettings": {  
                                "type": "JsonReadSettings"  
                            }  
                        },  
                        "sink": {  
                            "type": "AzureSqlSink",  
                            "writeBehavior": "insert",  
                            "sqlWriterUseTableLock": false  
                        },  
                        "enableStaging": false,  
                        "translator": {  
                            "type": "TabularTranslator",  
                            "mappings": [  
                                {  
                                    "source": {  
                                        "path": "['id']"  
                                    },  
                                    "sink": {  
                                        "name": "col1",  
                                        "type": "String"  
                                    }  
                                },  
                                {  
                                    "source": {  
                                        "path": "['displayName']"  
                                    },  
                                    "sink": {  
                                        "name": "col2",  
                                        "type": "String"  
                                    }  
                                },  
                                {  
                                    "source": {  
                                        "path": "$['lowdata']"  
                                    },  
                                    "sink": {  
                                        "name": "col3",  
                                        "type": "String"  
                                    }  
                                },  
                                {  
                                    "source": {  
                                        "path": "$['time']"  
                                    },  
                                    "sink": {  
                                        "name": "col4",  
                                        "type": "String"  
                                    }  
                                }  
                            ],  
                            "collectionReference": "$['value']",  
                            "mapComplexValuesToString": true  
                        }  
                    },  
                    "inputs": [  
                        {  
                            "referenceName": "disper",  
                            "type": "DatasetReference"  
                        }  
                    ],  
                    "outputs": [  
                        {  
                            "referenceName": "AzureSqlTable2",  
                            "type": "DatasetReference"  
                        }  
                    ]  
                }  
            ],  
            "annotations": []  
        }  
    }  
    
    1 person found this answer helpful.

Your answer

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