Azure Data Factory - Copy Activity REST API (as sink) Error "The body must be an object"

Ravinder 5 Reputation points
2023-01-19T06:45:48.0233333+00:00

I am using Copy Activity to read data from a Table and sending the output rows to a REST API via POST request. While doing so i get an error on sink side:

"status": { "code": 300, "message": "INVALID_OR_MISSING_REQUEST" }, "errors": [ { "code": "body", "message": "The body must be an object." } ] },Source=Microsoft.DataTransfer.ClientLibrary,'

When i import schema, it automatically maps the columns for me as below:

Copy Activity Mapping

Problem seems to be in how ADF is formatting output vs how REST endpoint expects data. I tried to manually send JSON data from a Web Activity that works:

{
    "users": [
        {
            "firstName": "Test",
            "lastName": "Test",
            "email": "test@abc.com",
            "phone": "88888888",
            "userId": "88888888",
            "Points": "1111",
            "Month": "February"
        }
    ]
}

To test copy activity output JSON format, i tried sending data to a logic app endpoint and format seems to be different than expected by API endpoint:

 "body": [
        {
           "firstName": "Test",
            "lastName": "Test",
            "email": "test@abc.com",
            "phone": "88888888",
            "userId": "88888888",
            "Points": "1111",
            "Month": "February"
        }
	]

What do i need to do to map it correctly.

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