Dirk Sachse
Dirk Sachse

Reputation: 67

Using a variable in the Request Body form in Azure Data Factory Copy Data activity

Is it possible to use a variable in the "Request body" field in a Copy data activity?

This is my pipeline:

enter image description here

Output of "Get requestBody":

enter image description here

Allready full of unwanted slashes.

Output of "Set variable":

enter image description here

I using this expression in the "Request body" Field:

@replace(variables('requestBody'),'\','')

enter image description here

This is the input of "Copy data":

enter image description here

I cant get rid of all slashes. Is it even possible to use a variable for "Request body"?

Upvotes: 0

Views: 2601

Answers (2)

Dirk Sachse
Dirk Sachse

Reputation: 67

To remove the backslashes, I had to use this:

@replace(string(variables('requestBody')), '\"', '"')

Upvotes: 0

NiharikaMoola
NiharikaMoola

Reputation: 5074

As your lookup activity output returns JSON string value it includes an escape character backslash '\'.

To remove the escape character, create an array type variable and convert the lookup out to JSON array in append variable activity as below.

  1. Create array variable.

enter image description here

  1. Lookup output: As I checked firstrow only property in lookup activity, the output results firstrow only.

enter image description here

  1. In the Append variable activity, get the lookup output and convert it to JSON array.

@json(activity('Lookup1').output.firstrow.requestbody)

enter image description here

  1. Append variable result: Use this variable in later activities.

enter image description here

You can refer to these SO & SO threads for reference.

Upvotes: 1

Related Questions