question

PraveenNayakwadi-2744 avatar image
0 Votes"
PraveenNayakwadi-2744 asked ShaikMaheer-MSFT commented

Azure Data Factory Rest APi Dynamic Maping not working

Hello ,
I'm trying to dynamically map rest api to sql server using copy task with an example json output as below

       {
          "country_code":"US",
            
          "alerts":[
             {
                "regions":[
                   "Madison",
                   " Franklin"
                    
                ],
                "ends_utc":"2020-10-17T13:00:00",
               
                "onset_local":"2020-10-17T02:00:00",
   
                "description":"*  temperatures low and high winds ."
             }
          ],
          "city_name":"Dayton",
          "state_code":"OH"
       }


with

a map expression
as below
@json(' {
"type": "TabularTranslator",
"mappings": [ { "source": { "path": "$[''alerts''][0][''description'']"
},
"sink": {
"name": "description",
"type": "String"
}
},
{
"source": {
"path": "$[''city_name'']"
},
"sink": {
"name": "city_name",
"type": "String"
}
}
],
"collectionReference": "",
"mapComplexValuesToString": true
}')

The out put is only getting values for city but not for description.



azure-data-factory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ShaikMaheer-MSFT avatar image
0 Votes"
ShaikMaheer-MSFT answered ShaikMaheer-MSFT commented

Hi @PraveenNayakwadi-2744 ,

Welcome to Microsoft Q&A Platform. Thank you for posting your query here.

It seems small syntax error in your json, Kindly use below syntax to access "description" property. I added . after [0] in json.

 "source": 
     { 
        "path": "$[''alerts''][0].[''description'']"
     },
 "sink": 
     {
         "name": "description",
         "type": "String"
         }

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


  • Please accept an answer if correct. 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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello,
Thanks for the correction ,its working now ,I'm able to retrieve the data for the field.

0 Votes 0 ·

Hi @PraveenNayakwadi-2744 ,

Glad to know that your issue resolved. Thank you for accepting answer.

0 Votes 0 ·