I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.
Issue:
I have a pipeline in Azure Data Factory that has a Copy data Activity with an Azure blob storage source(contains JSON files which each have a single JSON object) and a REST sink. I am sending a PUT request and the API endpoint I am sending the request to expects a JSON object, not an array. I cannot change what the API expects.
On the Microsoft learn page for data factory, REST as Sink https://learn.microsoft.com/en-us/azure/data-factory/connector-rest?tabs=data-factory#rest-as-sink it specifies that the JSON will be sent with the following format:
JSONAI ConvertCopy
[
{ <data object> },
{ <data object> },
...
]
Is there any way to change the settings or customize the REST sink so it sends the JSON in the below format instead? Or another connector that would be better suited to this?
JSONAI ConvertCopy
{ <data object> }
NOTE: When I have tested this with one file it still sends in array format, just with one element:
JSONAI ConvertCopy
[
{ <data object> }
]
Solution:
I have found a way using a Lookup Activity and a Web Activity. Use a Lookup activity to grab a single or multiple JSON file(s) from the Blob Storage, this will be the output of the Lookup activity. A Web Activity can then be triggered after the completion of the Lookup Activity. In the Web Activity you must specify the body of the message, in which you can use dynamic content to insert the output of the Lookup activity like so:
YAMLAI ConvertCopy
@activity('Lookup
This will grab the first JSON object found from the Lookup Activity (firstRow), thus only the JSON object will be sent as the body rather than an array of JSON objects.
If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.
Hope this helps. Do let us know if you have any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.