ADF, CopyData & Rest API

Michaël OULLION 26 Reputation points
2022-09-09T07:52:14.45+00:00

I actually try to make a simple pipeline to read JSON Data on a API REST and store it in a database.

I try first with a CopyData acticity. I set up the linked service, the dataset, etc etc...

I need to call an API with POST Method and a Body's payload. Everything is set, I launch the pipeline and... the api respond like i don't providethe Body's payload.

Double check it, check it via the generated json :

ADF: Body request - seems ok

and in the generated pipeline JSON

...
"source": {
"type": "RestSource",
"httpRequestTimeout": "00:01:40",
"requestInterval": "00.00:00:00.010",
"requestMethod": "POST",
"requestBody": "{ \"startDate\":\"2022-09-01T00:00\", \"endDate\":\"2022-09-01T23:59\"}"
},
...

Because requestBody wait a string type, the double quote are escaped... Never wanted to work. Nothing to do. API never seems to find the body.

I find the "Web" activity and I decide to give it a quick try.

Same api call,same linked service, same dataset same url, same method, same body payload... Just a big copy&paste.

And it's work... So, why Web activity works and not CopyData?

I reopen the generated pipeline's JSON and :

Web Activity:

"body": {
"startDate": "2022-09-01T00:00",
"endDate": "2022-09-01T23:59"
},

Copy Activity:

"requestBody": "{ \"startDate\":\"2022-09-01T00:00\", \"endDate\":\"2022-09-01T23:59\"}"

Seems that Web activity don't request the body type to be a String. Maybe it's the problem, Maybe Copy rewrite body "badly" and it's fail.

So, Do I miss something? or Is it a bug?

And how do you do it? (consume API data in adf pipeline)

Cheers, Mike.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,521 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 32,661 Reputation points Microsoft Employee
    2022-09-09T15:12:55.613+00:00

    Hi @Michaël OULLION ,

    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    As I understand your issue, you are trying to make a POST call to REST API using Copy activity and it's failing . However, when you send the same POST request to the same API via Web activity, it works well. Please let me know if my understanding is incorrect.

    I tried to reproduce your scenario, but it's working well for me in both the cases. So, it's definitely not a bug.

    Kindly make sure you are providing correct authentication details and headers.

    Sharing the video for your reference:

    239547-restapicall.gif

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful

Your answer

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