Home > Net >  How do you handle an empty Rest call when trying to copy data in azure data factory?
How do you handle an empty Rest call when trying to copy data in azure data factory?

Time:03-29

I have a copy data activity in which my source dataset is set to a RestResource. It works fine except for every once in a while the Rest call returns an empty dataset: {"d":{"results":[]}}

This results in the following error

{
    "errorCode": "2200",
    "message": "ErrorCode=UserErrorTypeInSchemaTableNotSupported,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to get the type from schema table. This could be caused by missing Sql Server System CLR Types.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.InvalidCastException,Message=Unable to cast object of type 'System.DBNull' to type 'System.Type'.,Source=Microsoft.DataTransfer.ClientLibrary,'",
    "failureType": "UserError",
    "target": "Import Punch Adjustments",
    "details": []
}

I know for other sources you would want to do a lookup or check the metadata then do a conditional if, but I am unsure how to do that for a rest source. Are there any other better options?

CodePudding user response:

You can add an activity on failure, this way even the copy activity fails pipeline will run successfully.

Example:

I have added an activity to store the error code on failure.

@string(activity('Copy data1').Error.errorCode)

enter image description here

enter image description here

Pipeline status:

enter image description here

  • Related