- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
JOLT spec to decide the value based on content
- Labels:
-
Apache NiFi
Created 03-19-2018 11:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am enriching my request payload with the payload attribute 'http.headers.orgId' and its working fine.
SPEC:
[{ "operation": "default",
"spec": {
"*": { "orgId": "${http.headers.orgId}" }
}
}]
INPUT :
{ "drivewiseDeviceData": { "imei": "sampleimei", "tripId": "3d9df81a-1828-40eb-940e-d2434eb5f50f", "sumVer": null, "payloadType": "Binary", "packetInfo": "", "payloadData": "g1bjSWX", "recordinfo": null, "sequenceNum": null, "timeStamp": "2017-05-26T12:07:29.968Z" } }
OUTPUT:
{ "drivewiseDeviceData": { "imei": "sampleimei", "tripId": "3d9df81a-1828-40eb-940e-d2434eb5f50f", "sumVer": null, "payloadType": "Binary", "packetInfo": "", "payloadData": "g1bjSWX", "recordinfo": null, "sequenceNum": null, "timeStamp": "2017-05-26T12:07:29.968Z", "orgId": "Sample Org Name Here" } }
.........................................................................................................................................
Now scenarios is I may get header attribute as 'http.headers.OrgID' or 'http.headers.orgId',
So is there any way to handle both scenarios in my JOLT spec?
If 'http.headers.orgId' value is null/empty/attribute-not-present then I should use 'http.headers.OrgID' for enrich.
Created 03-21-2018 01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should be able to use UpdateAttribute with ExpressionLanguage (probably the ifElse() function along with isNull()) in order to set http.headers.orgId to http.headers.OrgID if it is not already populated. Then you can keep the JOLT spec as-is.
Created 03-21-2018 01:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should be able to use UpdateAttribute with ExpressionLanguage (probably the ifElse() function along with isNull()) in order to set http.headers.orgId to http.headers.OrgID if it is not already populated. Then you can keep the JOLT spec as-is.
