Getting individual array elements from the data returned by a chainlink external adapter - chainlink

In the job I'm adding for my external adapter, I'm looking to get results for the first 3 elements in the Results array one at a time.(see the data returned from my external adapter below)
So I'm adding "position" to my chainlink request in the consumer contract and wanting to use that in the jsonparse like below, rather than pass it to the external adapter. However, I get this error JSONParse task error: $(decode_cbor.position) is not a valid array index
parse [type=jsonparse path="data,MRData,RaceTable,Races,0,Results,$(decode_cbor.position),number" data="$(fetch)"]```
in my consumer contract
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
request.add("position", "1");
The data returned from the external adapter looks like this.
{
"MRData": {
"xmlns": "http://ergast.com/mrd/1.4",
"series": "f1",
"url": "http://ergast.com/api/f1/current/last/results.json",
"limit": "30",
"offset": "0",
"total": "20",
"RaceTable": {
"season": "2021",
"round": "17",
"Races": [{
"season": "2021",
"round": "17",
"url": "http://en.wikipedia.org/wiki/2021_United_States_Grand_Prix",
"raceName": "United States Grand Prix",
"Circuit": {
"circuitId": "americas",
"url": "http://en.wikipedia.org/wiki/Circuit_of_the_Americas",
"circuitName": "Circuit of the Americas",
"Location": {
"lat": "30.1328",
"long": "-97.6411",
"locality": "Austin",
"country": "USA"
}
},
"date": "2021-10-24",
"time": "19:00:00Z",
"Results": [{
"number": "33",
"position": "1",
"positionText": "1",
"points": "25",
"Driver": {
"driverId": "max_verstappen",
"permanentNumber": "33",
"code": "VER",
"url": "http://en.wikipedia.org/wiki/Max_Verstappen",
"givenName": "Max",
"familyName": "Verstappen",
"dateOfBirth": "1997-09-30",
"nationality": "Dutch"
},.....
The full results can be found here. http://ergast.com/api/f1/current/last/results.json
Should I be able to do something like this? Is there a better way to go about this? Should I edit the adapter instead?
schemaVersion = 1
name = "f1latestresults2"
contractAddress = "0x765aCc258f3a7b2D8d103D1A9310fc51b07D5425"
maxTaskDuration = "0s"
observationSource = """
decode_log [type=ethabidecodelog
abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"]
decode_cbor [type=cborparse data="$(decode_log.data)"]
fetch [type=bridge name="raceresults" requestData="{\\"id\\":$(jobSpec.externalJobID),\\"data\\":{\\"position\\":\\"0\\"}}"]
parse [type=jsonparse path="data,MRData,RaceTable,Races,0,Results,$(decode_cbor.position),number" data="$(fetch)"]
encode_data [type=ethabiencode abi="(uint256 value)" data="{ \\"value\\": $(parse) }"]
encode_tx [type=ethabiencode
abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_data)}"
]
submit_tx [type=ethtx to="0x765aCc258f3a7b2D8d103D1A9310fc51b07D5425" data="$(encode_tx)"]
decode_log -> decode_cbor -> fetch -> parse -> encode_data -> encode_tx -> submit_tx
"""
externalJobID = "cfa059b4-a31d-4c30-99e4-3a2fd4c57739"

The syntax you are using looks correct to me, so I'm not 100% sure if the TOML jobs can support having a parameter like that within a string yet?
If the rest of the JSON path is static, suggest just having it as a built up string in your consuming contract, and just sending it as a full string in the request, then using that in your TOML spec, similar to the example in the docs
req.add("path", "data,MRData,RaceTable,Races,0,Results,0");
Then in your TOML job spec:
parse [type=jsonparse path="$(decode_cbor.path)" data="$(fetch)"]

Related

Apollo cache error on deleted "child" table

NOTE: the __typename Client below refers to a person (like a customer) - not client/server.
Getting the following error:
Cache data may be lost when replacing the clientServices field of a Client object.
To address this problem (which is not a bug in Apollo Client), define a custom merge function for the Client.clientServices field, so InMemoryCache can safely merge these objects:
existing: [{"__ref":"ClientService:46"}]
incoming: []
What's happening is that I've deleted a "child" record - so there's no data.
First time I get this returned. Note: there's info associated with field clientServices
{
"client": {
"id": "41",
"companyId": "3",
"firstName": "Lew",
"lastName": "Terry",
"email": "lewterry#diamond.com",
"clientServices": [
{
"id": "46",
"serviceId": "13",
"description": "Individual psychotherapy - 45 minutes",
"sessionFee": 90,
"cptCode": "90834",
"__typename": "ClientService"
}
],
"__typename": "Client"
}
}
And here's the results on a refetch after the client record is saved and the clientServices "child" data has been deleted so it's an empty array.
{
"client": {
"id": "41",
"companyId": "3",
"firstName": "Lew",
"lastName": "Terry",
"email": "lewterry#diamond.com",
clientServices: []
"__typename": "Client"
}
}
Do I really need a custom merge? Or is there another solution?

Transforming XML to JSON using dataweave

Request to please help me with the dataweave to achieve below output. Here we need to do the following.
We need to add default values when XML element is null.
We need to map all the repeating elements inside XML element to their corresponding parent XML element.
I tried writing the dataweave for the same but was not able to achieve the desired response.
Request
<PacketResponse>
<PackResult>
<Result>0</Result>
<packs>
<pack>
<SeqNo>1</SeqNo>
<PackNumber>2550082245045</PackNumber>
<packageDate>2022-07-08T13:31:55.917+02:00</packageDate>
<Values i:nil="true"/>
</pack>
<pack>
<SeqNo>2</SeqNo>
<PackNumber>2550256260676</PackNumber>
<packageDate>2022-07-27T08:36:18.12+02:00</packageDate>
<Values>
<GetPackValue>
<Code>000228</Code>
<Count>80</Count>
<Amount>1600.00</Amount>
</GetPackValue>
<GetPackValue>
<Code>000227</Code>
<Count>20</Count>
<Amount>200.00</Amount>
</GetPackValue>
<GetPackValue>
<Code>000229</Code>
<Count>40</Count>
<Amount>2000.00</Amount>
</GetPackValue>
</Values>
</pack>
<pack>
<SeqNo>3</SeqNo>
<PackNumber>2550326072025</PackNumber>
<packageDate>2022-08-09T13:17:43.197+02:00</packageDate>
<Values>
<GetPackValue>
<Code>000240</Code>
<Count>5</Count>
<Amount>260.00</Amount>
</GetPackValue>
</Values>
</pack>
</packs>
</PackResult>
</PacketResponse>
Expected Response
[
{
"seqNo": "1",
"PackNumber": "2550082245045",
"packageDate": "2022-07-08 01:31:55",
"code": "000000",
"count": 0,
"amount": 0
},
{
"seqNo": "2",
"PackNumber": "2550256260676",
"code": "000228",
"packageDate": "2022-07-27 08:36:18",
"count": "80",
"amount": 1600.00
},
{
"seqNo": "2",
"PackNumber": "2550256260676",
"code": "000227",
"packageDate": "2022-07-27 08:36:18",
"count": "20",
"amount": 200.00
},
{
"seqNo": "2",
"PackNumber": "2550256260676",
"code": "000229",
"packageDate": "2022-07-27 08:36:18",
"count": "40",
"amount": 2000.00
},
{
"seqNo": "3",
"PackNumber": "2550326072025",
"code": "000240",
"packageDate": "2022-08-09 01:17:43",
"count": "5",
"amount": 260.00
}
]
I've used a combination of flatMap() and multi-value selector:
%dw 2.0
output application/json
---
payload.PacketResponse.PackResult.packs.*pack flatMap ((pack, index) -> do {
var packResult = {
seqNo: pack.SeqNo,
"PackNumber": pack.PackNumber,
"packageDate": pack.packageDate,
}
---
pack.Values.*GetPackValue map ((packValue, index) -> packResult ++ packValue) default ([packResult ++ {"code": "000000", "count": 0,"amount": 0}])
}
)
Here's an alternative way to do the same.
The key here is that you need to iterate for each of the GetPackValues but make sure to generate a value for the cases where there's no value too.
Here the pack.Values.*GetPackValue default [{}] takes care of that.
Finally since you have a nested Array because some Values have multiple GetPackValues, the flatMap takes care of flattening those results into a simple Array.
%dw 2.0
output application/json
---
payload.PacketResponse.PackResult.packs.*pack flatMap (pack) ->
pack.Values.*GetPackValue default [{}] map (value) -> {
"seqNo": pack.SeqNo,
"PackNumber": pack.PackNumber,
"packageDate": pack.packageDate,
"code": value.Code default "000000",
"count": value.Count default 0,
"amount": value.Amount default 0
}
Use multivalue selector and apply map on it, like mentioned below:
' %dw 2.0
output application/json
---
payload.PacketResponse.PackResult.*packs.*pack map ((item, index) -> {
seqNo: item.SeqNo,
PackNumber: item.PackNumber,
packageDate: item.packageDate,
code: item.Values.GetPackValue.Code default "",
count: item.Values.GetPackValue.Count default "",
amount: item.Values.GetPackValue.Amount default "
} ) '

Chainlink How to encode to bytes32 for results from external adapter?

I am trying to set up a job for an external adapter. I get the results from the api call. It processes all the way up to the task parse. But when I try the task Ethabiencode I get this error:
encode_data ethabiencode
ETHABIEncode: while converting argument 'value' from to bytes32: cannot convert decimal.Decimal to [32]uint8: bad input for task: bad input for task
abi: (bytes32 value)
data: { "value": $(multiply) }
Is the value from $(parse) there? or is it nil?
I am running v0.10.15
here's the job
type = "directrequest"
schemaVersion = 1
name = "Get > Bytes32"
contractAddress = "0x4dbDef7A9E395831FD2aD5754F6Bf81707017e28"
maxTaskDuration = "0s"
observationSource = """
decode_log [type="ethabidecodelog"
abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"]
decode_cbor [type="cborparse" data="$(decode_log.data)"]
fetch [type=bridge name="bet-ea" async="True" requestData="{\\"id\\": $(jobSpec.externalJobID), \\"data\\": { \\"fixtureId\\": $(decode_cbor.fixtureId)}}"]
parse [type="jsonparse" lax="True" path="result" data="$(fetch)"]
encode_data [type="ethabiencode" abi="(bytes32 value)" data="{ \\"value\\": $(parse) }"]
encode_tx [type="ethabiencode"
abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
data="{\\"requestId\\": $(decode_log.requestId), \\"payment\\": $(decode_log.payment), \\"callbackAddress\\": $(decode_log.callbackAddr), \\"callbackFunctionId\\": $(decode_log.callbackFunctionId), \\"expiration\\": $(decode_log.cancelExpiration), \\"data\\": $(encode_data)}"
]
submit_tx [type="ethtx" to="0x4dbDef7A9E395831FD2aD5754F6Bf81707017e28" data="$(encode_tx)"]
decode_log -> decode_cbor -> fetch -> parse -> encode_data -> encode_tx -> submit_tx
"""
externalJobID = "19f6be23-b75c-4858-9e7a-be02679b83cc"
{
"outputs": [
null
],
"errors": [
"task inputs: too many errors"
],
"inputs": {
"jobRun": {
"logAddress": "0xd2de9f0bbe99c7100f8456548cddb33103122e57",
"logBlockHash": "0x3ced7cf22e1b368b3c57580e66721dd632a216414c82caa26d6548b7a0aca842",
"logBlockNumber": 5292158,
"logData": "AAAAAAAAAAAAAAAACvp9jgodQj3rZ71Dh9pqxgl+Vjjydtvwp78RTtc+VslKVNFOPNmD4kPnG/qlvDyrZ/tyqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3gtrOnZAAAAAAAAAAAAAAAAAAACvp9jgodQj3rZ71Dh9pqxgl+VjhJVWr/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABh8BvmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARaWZpeHR1cmVJZGY3MTA1ODAAAAAAAAAAAAAAAAAAAAA=",
"logTopics": [
"0xd8d7ecc4800d25fa53ce0372f13a416d98907a7ef3d8d3bdd79cf4fe75529c65",
"0x6231653236353232353131383431613562636666333864336333326337353663"
],
"logTxHash": "0xf9c543ef3a4ca858ad7944af3b0970246f0002fcd76df5610b2be53b90a463ad",
"meta": {
"oracleRequest": {
"callbackAddr": "0x0aFA7d8e0A1d423Deb67BD4387Da6ac6097E5638",
"callbackFunctionId": "0x49556aff",
"cancelExpiration": "1643125734",
"data": "0x6966697874757265496466373130353830",
"dataVersion": "1",
"payment": "1000000000000000000",
"requestId": "0xf276dbf0a7bf114ed73e56c94a54d14e3cd983e243e71bfaa5bc3cab67fb72a8",
"requester": "0x0aFA7d8e0A1d423Deb67BD4387Da6ac6097E5638",
"specId": "0x6231653236353232353131383431613562636666333864336333326337353663"
}
}
},
"jobSpec": {
"databaseID": 36,
"externalJobID": "b1e26522-5118-41a5-bcff-38d3c32c756c",
"name": "Get > Bytes32"
}
},
"taskRuns": [
{
"type": "ethtx",
"createdAt": "2022-01-25T15:43:55.888153Z",
"finishedAt": "2022-01-25T15:43:57.688118Z",
"output": null,
"error": "task inputs: too many errors",
"dotId": "submit_tx",
"status": "not_run"
},
{
"type": "ethabidecodelog",
"createdAt": "2022-01-25T15:43:55.8927Z",
"finishedAt": "2022-01-25T15:43:55.8928Z",
"output": "{"callbackAddr":"0x0afa7d8e0a1d423deb67bd4387da6ac6097e5638","callbackFunctionId":[73,85,106,255],"cancelExpiration":1643125734,"data":"aWZpeHR1cmVJZGY3MTA1ODA=","dataVersion":1,"payment":1000000000000000000,"requestId":[242,118,219,240,167,191,17,78,215,62,86,201,74,84,209,78,60,217,131,226,67,231,27,250,165,188,60,171,103,251,114,168],"requester":"0x0afa7d8e0a1d423deb67bd4387da6ac6097e5638","specId":[98,49,101,50,54,53,50,50,53,49,49,56,52,49,97,53,98,99,102,102,51,56,100,51,99,51,50,99,55,53,54,99]}",
"error": null,
"dotId": "decode_log",
"status": "completed"
},
{
"type": "cborparse",
"createdAt": "2022-01-25T15:43:55.89282Z",
"finishedAt": "2022-01-25T15:43:55.892849Z",
"output": "{"fixtureId":"710580"}",
"error": null,
"dotId": "decode_cbor",
"status": "completed"
},
{
"type": "bridge",
"createdAt": "2022-01-25T15:43:55.892858Z",
"finishedAt": "2022-01-25T15:43:57.687947Z",
"output": ""{\"jobRunID\":\"1\",\"data\":{\"winner\":7105801,\"result\":7105801},\"result\":7105801,\"statusCode\":200}"",
"error": null,
"dotId": "fetch",
"status": "completed"
},
{
"type": "jsonparse",
"createdAt": "2022-01-25T15:43:57.68797Z",
"finishedAt": "2022-01-25T15:43:57.687988Z",
"output": "7105801",
"error": null,
"dotId": "parse",
"status": "completed"
},
{
"type": "ethabiencode",
"createdAt": "2022-01-25T15:43:57.688014Z",
"finishedAt": "2022-01-25T15:43:57.688071Z",
"output": null,
"error": "ETHABIEncode: while converting argument 'value' from <nil> to bytes32: cannot convert float64 to [32]uint8: bad input for task: bad input for task",
"dotId": "encode_data",
"status": "errored"
},
{
"type": "ethabiencode",
"createdAt": "2022-01-25T15:43:57.688093Z",
"finishedAt": "2022-01-25T15:43:57.688096Z",
"output": null,
"error": "task inputs: too many errors",
"dotId": "encode_tx",
"status": "errored"
}
],
"createdAt": "2022-01-25T15:43:55.886335Z",
"finishedAt": "2022-01-25T15:43:57.688124Z",
"pipelineSpec": {
"id": 36,
"jobID": 0,
"dotDagSource": " decode_log [type="ethabidecodelog" abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)" data="$(jobRun.logData)" topics="$(jobRun.logTopics)"] decode_cbor [type="cborparse" data="$(decode_log.data)"] fetch [type=bridge name="bet-ea" requestData="{\"id\": $(jobSpec.externalJobID), \"data\": { \"fixtureId\": $(decode_cbor.fixtureId)}}"] parse [type="jsonparse" path="result" data="$(fetch)"] encode_data [type="ethabiencode" abi="(bytes32 value)" data="{ \"value\": $(parse) }"] encode_tx [type="ethabiencode" abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)" data="{\"requestId\": $(decode_log.requestId), \"payment\": $(decode_log.payment), \"callbackAddress\": $(decode_log.callbackAddr), \"callbackFunctionId\": $(decode_log.callbackFunctionId), \"expiration\": $(decode_log.cancelExpiration), \"data\": $(encode_data)}" ] submit_tx [type="ethtx" to="0xD2DE9f0bBe99C7100f8456548cDDb33103122e57" data="$(encode_tx)"] decode_log -> decode_cbor -> fetch -> parse -> encode_data -> encode_tx -> submit_tx "
},
"id": "32",
"jobId": "36",
"status": "errored",
"type": "Pipeline job run"
}

I used StartsWith but its not working in azure cosmosDB documents through linq

I have used STARTSWITH to filter the records through linq to fetch the data from azure cosmos db. but it always shows the record count as zero.
The query used to fetch the data:
var locs = from data
in locations
where data.Properties.Street.ToLower().StartsWith("chest")
select data;
Here's a sample from the document database:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-0.141246,
51.56292
]
},
"properties": {
"city": "london",
"countryCode": "GB",
"parkingType": "permit holders only",
"approxNoOfSpaces": 4,
"timesOfOperation": "mon-fri 10:00-12:00",
"maximumStay": "N/A",
"tariff": "N/A",
"cashlessIdentifier": "N/A",
"nearestMachine": "N/A",
"street": "Chester Road",
"postcode": "N19 5DE",
"controlledParkingZone": "CA-U",
"validParkingPermits": "CA-U",
"parkingBayLengthMetres": 19,
"disclaimer": "The information provider and/ or licensor are not liable for any errors or omissions contained within this dataset and shall not be liable for any loss, injury or damage caused by its use.",
"easting": 528937,
"northing": 186530,
"EPSG:27700 Well Known Text Geometry": "LINESTRING (528943.9746311313 186522.8076569282,528944.9970187079 186524.33721909559,528929.9827624428 186537.32350181084,528928.7624933998 186535.9039081653)",
"EPSG:4326 Well Known Text Geometry": "LINESTRING (-0.14114833166779203 51.56285353559299,-0.14113302974759298 51.56286704785321,-0.14134475707247782 51.56298717904703,-0.14136287187179347 51.56297470018317)",
"externalFeatureId": 46044821,
"spatialAccuracy": "Defined By Custodian",
"lastUploaded": "07/08/2019 11:01:52 PM",
"location": "(51.56292, -0.141246)",
"organisationURI": "http://opendatacommunities.org/id/london-borough-council/camden",
":#computed_region_hxwp_gyfc": 10,
":#computed_region_6i9a_26nj": 66
},
"documentType": "location",
"id": "********************",
"_rid": "*******************",
"_self": "****************************",
"_etag": "*****************************",
"_attachments": "********************",
"_ts": 1565344913
}

zoho books custom function with deluge

I'm creating a custom function in zoho books that will create a record in zoho creator using payment record information from zoho books. I've been able to successfully create a record in zoho creator but I'm unable to get the invoice_id from the customer_payment map.
Unfortunately, there's no error being thrown.
Below is the code:
paymentMap = Map();
//set order to payment invoice id - this is not working
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));
paymentMap.put("Description",customer_payment.get("card_type"));
paymentMap.put("Payment_ZB_ID",customer_payment.get("payment_id"));
response = zoho.creator.createRecord("XXXXX","XX","Payment",paymentMap);
info response;
Below is the map that is available:
customer_payment
{
"payment_id": "11111111111111111",
"payment_number": "1",
"payment_number_prefix": "",
"payment_number_suffix": "1",
"documents": [],
"customer_id": "11111111111111111",
"customer_name": "John Doe",
"payment_mode": "Stripe",
"card_type": "visa",
"card_type_formatted": "Visa",
"date": "2019-03-04",
"date_formatted": "03/04/2019",
"account_id": "11111111111111111",
"account_name": "Stripe Clearing",
"account_type": "payment_clearing",
"account_type_formatted": "Payment Clearing Account",
"currency_id": "11111111111111111",
"currency_code": "USD",
"exchange_rate": 1,
"exchange_rate_formatted": "$1.00",
"amount": 1,
"amount_formatted": "$1.00",
"unused_amount": 0,
"unused_amount_formatted": "$0.00",
"bank_charges": 0.33,
"bank_charges_formatted": "$0.33",
"tax_account_id": "",
"is_client_review_settings_enabled": false,
"tax_account_name": "",
"tax_amount_withheld": 0,
"tax_amount_withheld_formatted": "$0.00",
"discount_amount": 0,
"discount_amount_formatted": "$0.00",
"description": "Stripe processing fees : $0.33 ",
"reference_number": "12345",
"online_transaction_id": "12345",
"settlement_status": "",
"settlement_status_formatted": "",
"invoices": [
{
"invoice_number": "11111111111111111",
"invoice_payment_id": "11111111111111111",
"invoice_id": "11111111111111111",
"amount_applied": 1,
"amount_applied_formatted": "$1.00",
"tax_amount_withheld": 0,
"tax_amount_withheld_formatted": "$0.00",
"discount_amount": 0,
"discount_amount_formatted": "$0.00",
"total": 1,
"total_formatted": "$1.00",
"balance": 0,
"balance_formatted": "$0.00",
"date": "2019-03-04",
"date_formatted": "03/04/2019",
"due_date": "2019-03-04",
"due_date_formatted": "03/04/2019",
"price_precision": 2,
"apply_date": "",
"apply_date_formatted": ""
}
],
"payment_refunds": [],
"last_four_digits": "1234",
"template_id": "11111111111111111",
"template_name": "Elite Template",
"page_width": "8.27in",
"page_height": "11.69in",
"orientation": "portrait",
"template_type": "elite",
"template_type_formatted": "Elite",
"attachment_name": "",
"can_send_in_mail": true,
"can_send_payment_sms": false,
"is_payment_details_required": true,
"custom_fields": [],
"custom_field_hash": {},
"imported_transactions": []
}
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));
Deluge does not throw an error here. Instead, when an element whose key is not available is being fetched, it throws a null.
The key used in ur code snippet invoices[0].invoice_id is not a valid key in the customer_payment map. So, this has been throwing a null value which would have populated as an empty (or no) value in Zoho Creator.
If you notice the customer_payment clearly, all invoices are available under the key "invoices".
invoices = customer_payment.get("invoices");// now invoices will have the list of invoices in customer_payment map
Assuming that the payment has only one invoice, the invoice ID can be extracted as below:
invoiceId = invoices.getJson("invoice_id");
It is also possible to extract the invoice ID as you have tried, like the below:
info customer_payment.get("invoices").get(0).get("invoice_id");
You can fetch invoice_id like this :
customer_payment = {"payment_id":"11111111111111111","payment_number":"1","payment_number_prefix":"","payment_number_suffix":"1","documents":{},"customer_id":"11111111111111111","customer_name":"John Doe","payment_mode":"Stripe","card_type":"visa","card_type_formatted":"Visa","date":"2019-03-04","date_formatted":"03/04/2019","account_id":"11111111111111111","account_name":"Stripe Clearing","account_type":"payment_clearing","account_type_formatted":"Payment Clearing Account","currency_id":"11111111111111111","currency_code":"USD","exchange_rate":1,"exchange_rate_formatted":"$1.00","amount":1,"amount_formatted":"$1.00","unused_amount":0,"unused_amount_formatted":"$0.00","bank_charges":0.33,"bank_charges_formatted":"$0.33","tax_account_id":"","is_client_review_settings_enabled":false,"tax_account_name":"","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","description":"Stripe processing fees : $0.33 ","reference_number":"12345","online_transaction_id":"12345","settlement_status":"","settlement_status_formatted":"","invoices":{{"invoice_number":"11111111111111111","invoice_payment_id":"11111111111111111","invoice_id":"11111111111111111","amount_applied":1,"amount_applied_formatted":"$1.00","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","total":1,"total_formatted":"$1.00","balance":0,"balance_formatted":"$0.00","date":"2019-03-04","date_formatted":"03/04/2019","due_date":"2019-03-04","due_date_formatted":"03/04/2019","price_precision":2,"apply_date":"","apply_date_formatted":""}},"payment_refunds":{},"last_four_digits":"1234","template_id":"11111111111111111","template_name":"Elite Template","page_width":"8.27in","page_height":"11.69in","orientation":"portrait","template_type":"elite","template_type_formatted":"Elite","attachment_name":"","can_send_in_mail":true,"can_send_payment_sms":false,"is_payment_details_required":true,"custom_fields":{},"custom_field_hash":{},"imported_transactions":{}};
invoices = customer_payment.getJson("invoices");
//info invoices;
invoiceId = invoices.getJSON("invoice_id");
info invoiceId;

Resources