Azure Function Activity in ADF - problem with passing Json to Azure Function

braxx 426 Reputation points
2021-01-12T17:11:13.417+00:00

I am trying to pass Json from ADF to Azure Function but getting the error on Azure Function Activity:

Call to provided Azure function 'TestFunction1' failed with status-'BadRequest' and message - 'Please pass a name on the query string or in the request body'.  

Here is a larger picture:
55832-capture61.png

And here is my Azure Function Activity:
55833-capture62.png

In my Lookup2 activity I simply have a parametrized store procedure which results are formatted to json:
55841-capture63.png

Here is the example of that json.

[  
	{  
		" Url": "https://www. 4714347",  
		" Title": "asdsfflkldsf",  
		"Initiative": "as5d",  
		"Start Date": "46130",  
	},  
	{  
		" Url": "https://www. 4717",  
		" Title": "asdsffdsf",  
		"Initiative": "asd",  
		"Start Date": "44130",  
	}  
]  

Not sure, why I am getting this error. Here is a similar case which works. Can’t figure out why my doesn’t.
https://stackoverflow.com/questions/63685948/how-to-pass-dynamic-parameter-to-azure-function
Would it be a matter that my function does not accept the body?

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

Accepted answer
  1. Nasreen Akter 10,751 Reputation points
    2021-01-12T18:45:44.187+00:00

    Hi @braxx ,

    It's hard to tell without knowing what are the parameters you are expecting in your Azure Function, but from the error msg, it looks like name is one of the parameters you wanted. If that is the case, request-body should look like the following:

    {  
     "name":[  
         {  
             "Url": "https://www. 4714347",  
             "Title": "asdsfflkldsf",  
             "Initiative": "as5d",  
             "Start Date": "46130"  
         },  
         {  
             "Url": "https://www. 4717",  
             "Title": "asdsffdsf",  
             "Initiative": "asd",  
             "Start Date": "44130"  
         }  
     ]  
    }  
    

    Please modify the SP accordingly and it should work. Here is an example:

    DECLARE @json _construct varchar(MAX) = '{"name": {X}}';
    DECLARE @json VARCHAR(MAX);

    SET @json = (SELECT col1, col2, col3 FROM dbo.Table FOR JSON PATH);

    SELECT REPLACE(@json _construct,'{X}', @json ) AS json_output;

    Please let me know if this helps. Thanks! :)

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful