Hello Akshay Patel,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that your dynamic mapping in ADF Copy Activity is not retrieving OData Formatted Values.
To really resolve this issue, this is my best recommendation:
- Use Data Flows to extract and map OData annotations instead of Copy Activity.
- Inspect the API response using a Web Activity before applying dynamic mapping.
- If Copy Activity must be used, first store API results in a staging area, then process annotations separately.
- Test the API response manually before running the pipeline to verify that formatted values are included.
With any of the two methods below, you should be able to retrieve the formatted value annotations (e.g., statecode@OData.Community.Display.V1.FormattedValue) dynamically in ADF Copy Activity.
METHOD 1: THIS IS TO USE DATA FLOW
- Use a Copy Activity to load raw API response (including annotations) into a staging table (Azure SQL, Blob Storage, or ADLS).
- Use a Data Flow to transform the data:
Use Derived Column
transformation to extract statecode@OData.Community.Display.V1.FormattedValue
.
Rename extracted fields before writing them to the destination. This is an example of Data Flow Derived Column Expression:
iif(contains(statecode, '@OData.Community.Display.V1.FormattedValue'), statecode['@OData.Community.Display.V1.FormattedValue'], 'Unknown')
- Load the transformed data into the final destination.
METHOD 2: THIS IS TO USE WEB ACTIVITY + COPY ACTIVITY
- Call the API with
Prefer = odata.include-annotations="*"
to inspect how the formatted values are returned. Then, parse the response in a Set Variable activity in web activity.
- Modify the JSON Mapping to Reference Extracted Annotations, instead of
statecode@OData.Community.Display.V1.FormattedValue
, create a derived field in the API response and map it dynamically. The below is a refine JSON mapping for dynamic retrieval of OData formatted values in ADF Copy Activity from your JSON, to ensure that:
- The Prefer header includes odata.include-annotations="*"`
- The dynamic mapping correctly references the @OData.Community.Display.V1.FormattedValue annotation .
{
"type": "TabularTranslator",
"mappings": [
{
"source": {
"name": "statecode@OData.Community.Display.V1.FormattedValue",
"type": "String"
},
"sink": {
"name": "statecode_formatted",
"type": "String"
}
},
{
"source": {
"name": "statecode",
"type": "Int32"
},
"sink": {
"name": "statecode",
"type": "Int32"
}
}
]
}
NOTE: Ensure that the API response contains the annotation as a top-level field before applying dynamic mapping.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.