Using HTTP or REST API as source in Copy Activity - error on source

M Price 1 Reputation point
2022-04-26T21:14:50.717+00:00

I have an Synapse pipeline that will make a call to a REST API returning a json response that I want to write to the data lake. My REST API call requires I pass a sessionId in the header. I first use a WebActivity to 'login' and retrieve the session Id. I then use a Copy Data activity with a HTTP json source. My sink is a json file in the data lake. I have 5 'Additional headers' that I must include when making my API call in the source, two of which reference my sessionId returned from the first Web activity. When I try Preview data on my source I get the following error:

Error occurred when deserializing source JSON file '../applications'. Check if the data is in valid JSON object format.
Unexpected character encountered while parsing value: <. Path '', line 0, position 0

When I run my pipeline it does complete, however the file that is written contains HTML instead of json and appears to be the result of the login failing.

I also tried using a REST API call as my source instead of the HTTP source. Both give me the same error on the Preview data of the source.

To test that my API call is passing the correct values in the header, I created a second pipeline containing a Web activity to 'login' and return the session Id, then I have a second Web activity that passes the 5 header values. This pipeline makes a successful call to my API and returns the expected result.

Here is what my pipeline looks like using an HTTP source with the Copy data activity:

196689-image.png

My Additional headers field looks like :
@{concat('Accept: application/json,Content-Type: application/json,Asc_xsrf_token: ',activity('Login').output.sessionId,',Range: items=0-999,Cookie: asc_session_id=',activity('Login').output.sessionId)}

This is what my pipeline looks like when using a REST API source:
196733-image.png

And my pipeline containing just a Web Activity to return the response looks like this. The Web activity returns a response as expected:
196743-image.png

Am I passing the headers correctly for the Copy data activity? Why would the Copy activity API call not work?
Is there a way to view the Request that is being sent for the source? That would help me debug this issue.

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 38,631 Reputation points Microsoft Employee Moderator
    2022-04-28T14:08:52.2+00:00

    Hi @M Price ,

    Thank you for posting query in Microsoft Q&A Platform.

    Could you please try using below string interpolation syntax while writing expression and see if that helps?
    Accept: application/json,Content-Type: application/json,Asc_xsrf_token: ',@{activity('Login').output.sessionId},',Range: items=0-999,Cookie: asc_session_id=',@{activity('Login').output.sessionId}

    Please let us know how it goes. Thank you.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.