Support Questions

Find answers, ask questions, and share your expertise

JOLT spec to decide the value based on content

avatar
Master Collaborator

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.

1 ACCEPTED SOLUTION

avatar
Master Guru

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.

View solution in original post

1 REPLY 1

avatar
Master Guru

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.