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:
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:
And my pipeline containing just a Web Activity to return the response looks like this. The Web activity returns a response as expected:
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.