Unexpected error on passing json value in azure data factory

Ankit Kumar 71 Reputation points
2022-01-05T12:05:08.06+00:00

0

I am calling an Azure Function(HTTP trigger) in Azure Data Factory and the body is coming from a lookup activity (@activity('Lookup1').output.value) which is something like this

"body":[
        {
            "BaseObject": "2|03|01|01",
            "BaseObjectDescription": "Cent",
            "CreateDate": "30.09.2021"
        },
        {
            "BaseObject": "9|03|01|01",
            "BaseObjectDescription": "Pent",
            "CreateDate": "30.09.2021"
        }]

The above json when passed as body to Azure function activity, I get error as

"Unexpected character encountered while parsing value: S."

But if I hardcode and pass the same value in body of Azure function in azure data factory, I get the output. When I hardcode it, I see in debug mode in Azure Data factory the body is passed as something like this

"body": "[\n        {\n            \"BaseObject\": \"02|03|01|01\",\n            \"BaseObjectDescription\": \"Cent\",\n            \"CreateDate\": \"30.09.2021\" },\n        {\n            \"BaseObject\": \"04|03|01|01\",\n            \"BaseObjectDescription\": \"Pent",\n            \"CreateDate\": \"21.09.2021\",\n },\n]"        

So question is how do I change the json I am getting from lookup activity to something like above so that my Function recognizes this as body in Azure Data Factory

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,639 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Niels 236 Reputation points
    2022-01-05T13:16:20.927+00:00

    Both outputs are the same, but in the last one you are seeing line break and escape characters. \n means a line break and \" means that the quote is escaped, because the whole string is enclosed in quotes.

    You should be focusing on where the error "Unexpected character encountered while parsing value: S." is coming from.


  2. Ankit Kumar 71 Reputation points
    2022-01-11T09:39:38.523+00:00

    For those who face this issue I solved it by putting the output in a variable and then passing the variable as a string in my Function activity body. This resolved the issue. Thanks


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.