0

This post Using XML with REST API through Azure Datafactory V2 says ADF does not support REST API with XML but since the post is 2 years old, I was wondering if Microsoft has enable this feature now?

EDIT

Currently I am doing like this where I am adding an addtional headers where I define it should be XML. However, the format still looks json when I preview the data. enter image description here

Alex K
  • 119
  • 1
  • 9

1 Answers1

1

We get this warning message while giving Accept header in copy activity saying application/json value will be automatically give as the value for this header.

enter image description here

  • Therefore, in copy data activity, the accepted API format is JSON only. As an alternate, you can use web activity and copy data to get the required response in the following way.

  • I used a sample API which returns XML response. I used this in the web activity and the debug output would be as follows:

enter image description here

  • The entire XML response is stored as a string. Now I have taken a copy data activity where the source is a CSV file (contents of this file don't matter. Try to take a file similar to below file).

enter image description here

  • Now, create an additional column for this source with any column name and value as shown below:
@activity('Web1').output.Response

enter image description here

  • Now, choose delimited text as the sink, with file name as op.xml and do not choose the first row as header option. Also select quote character as No quote character. The following is how I configured the sink dataset.

enter image description here

  • Now in mapping import schemas and keep only the above created additional column.

enter image description here

  • This will create a file op.xml at the destination storage account. The contents of the file would be as shown below:

enter image description here

  • Now you can use another copy data activity, choose XML as a the source file format and select the above generated op.xml file. When I preview the data, it is showing the data as expected.

enter image description here


Now, you can write this file to any required file format as per your requirement.

Saideep Arikontham
  • 5,558
  • 2
  • 3
  • 11
  • thanks for your description. One question, when using web acticity, is it possible to somehow use `Auth headers` just like in linked services when using REST ? – Alex K Nov 24 '22 at 13:02
  • Hey @AlexK, yes, you can give the Auth header same as in the REST API while using web activity as well. – Saideep Arikontham Nov 24 '22 at 16:41
  • I'm managed to load a xml content into a csv file but it is a string. I tried to create a data set with xml but I am not able to select it as a sink source. Must be a bug or something – Alex K Nov 24 '22 at 19:52
  • Copy data does not support XML as sink. That is the reason why I have loaded entire content as a string (which you managed to do) without quote character and then write it with file extension as `.xml` (even though selected sink is csv). Now read this file again using the copy data with XML dataset instead and then write it to necessary format (check the last 2 images for reference) – Saideep Arikontham Nov 25 '22 at 00:23
  • Hey @AlexK, has it worked? If not, try to provide the sink configuration of the above copy activity if the issue persists. – Saideep Arikontham Nov 25 '22 at 07:48
  • yes I just tried it now and it looks like it is working now – Alex K Nov 25 '22 at 08:05
  • also please note web activity cannot process output reposne greater than 4mb – Being Real Nov 26 '22 at 09:27