ADF copy activity for REST API POST requiring string value in request body field

Chuck Cox 5 Reputation points
2024-07-05T20:19:14.4266667+00:00

I have a ADF copy activity where my source is a REST API POST statement to a report process in one of our data sources. I have the parameters for the report stored in a SQL server table and I am calling it from a pipeline parameter. My expression for the request body field is this:

@json(pipeline().parameters.source_filter)

When the pipeline runs, the request body values look like this which look correct.

"requestBody": { "Name": "Solidigm FG Product Data Report-CSV", "ContainerPath": "/wt.inf.container.OrgContainer=Solidigm", "Criteria": []

But I am getting the following error:

Failure happened on 'Source' side. ErrorCode=UserErrorInvalidValueInPayload,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to convert the value in 'requestBody' property to 'System.String' type. Please make sure the payload structure and value are correct.,Source=Microsoft.DataTransfer.DataContracts,''Type=System.InvalidCastException,Message=Object must implement IConvertible.,Source=mscorlib,'

Per searches on the web, there is a suggestion for adding the REST header of this:

content-type: application/json

I already have this and still not working. I believe this is a bug with the copy statement.

any help is appreciated.

adf_issue

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,196 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 20,176 Reputation points
    2024-07-05T22:37:44.43+00:00

    You have an issue with your request body in the ADF copy activity. Verify that pipeline().parameters.source_filter is indeed a valid JSON string.

    You can explicitly convert your JSON object to a string. Here’s how you can do it:

    
    @string(pipeline().parameters.source_filter)
    

    As an alternative approach, you can use a Web Activity to perform the REST API POST request. This can help isolate whether the issue is specific to the Copy Activity. Here’s how you can configure a Web Activity:

    • URL: Set the endpoint of your REST API.
    • Method: POST
    • Headers:
        
        {
        
        "Content-Type": "application/json"
        
        }
        
      
    • Body: Use the same parameter:
        
        @string(pipeline().parameters.source_filter)