Reputation: 31
I have a job for an external adapter added to my local Chainlink node. It errors out when I make an initial request. My problem comes down to a syntax error or using the incorrect path. But I'm not aware of where to find out what the syntax should be. Or am I getting the path wrong?
Below is my job definition.
type = "directrequest"
schemaVersion = 1
name = "f1latestresults"
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[0],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 = "524e150a-b92b-48a3-b85b-abf7218d73f4"
This is a snippet of the data returned to the job.
{
"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
Upvotes: 1
Views: 98
Reputation: 856
Can you try remove the square brackets and use commas. ie instead of
Races[0]
Try
Races,0
ie:
data,MRData,RaceTable,Races,0,Results,0,number
If that doesn't work, please post your entire JSON output
Upvotes: 3