My aim is to pass some string to the data source and then process there and get back the result. Below given code works in solidity
oraclize_query("URL", "json(https://clever-ape-38.localtunnel.me).a","sfdg");
But when i try to fetch some value from blockchain and use it, if fails
string memory st = arr[msg.sender];
oraclize_query("URL", "json(https://clever-ape-38.localtunnel.me).a",st);
everything compiles properly. Even truffle migrate --reset works fine. I feel that the fetching from blockchain takes some time and oraclize_query() is called before the fetch.
Below there is mentioned the error.
[2019-05-28T08:54:50.206Z] INFO new HTTP query created, id: 72e3a263387ed365d97bc97a64c601380a5b4e8bbd1b3740bcc2af1e2bc97b19
[2019-05-28T08:54:50.215Z] INFO checking HTTP query 72e3a263387ed365d97bc97a64c601380a5b4e8bbd1b3740bcc2af1e2bc97b19 status in 0 seconds
[2019-05-28T08:54:50.215Z] INFO checking HTTP query 72e3a263387ed365d97bc97a64c601380a5b4e8bbd1b3740bcc2af1e2bc97b19 status every 5 seconds...
[2019-05-28T08:54:56.634Z] INFO 72e3a263387ed365d97bc97a64c601380a5b4e8bbd1b3740bcc2af1e2bc97b19 HTTP query result:
{
"result": {
"_timestamp": 1559033691,
"id": "72e3a263387ed365d97bc97a64c601380a5b4e8bbd1b3740bcc2af1e2bc97b19",
"daterange": [
1559033689,
1559035489
],
"_lock": false,
"id2": "72fdf59adf3ecc92244e3b173ce1657252ab5eb877c3569a393599d34dd2c848",
"actions": [],
"interval": 3600,
"checks": [
{
"errors": [
"TypeError",
"parsing_helper.wrong_path"
],
"success": true,
"timestamp": 1559033691,
"results": [
""
],
"proofs": [
null
],
"match": true
}
],
"version": 3,
"_timestamp_creation": 1559033689,
"context": {
"protocol": "eth",
"relative_timestamp": 1559033687,
"type": "blockchain",
"name": "eth_AB65E563DB"
},
"active": false,
"hidden": false,
"payload": {
"conditions": [
{
"query": [
"json(https://purple-squid-54.localtunnel.me).a",
"28189689"
],
"proof_type": 0,
"check_op": "tautology",
"datasource": "URL",
"value": null
}
]
}
},
"success": true
}
[2019-05-28T08:54:56.637Z] ERROR HTTP query error
[
"TypeError",
"parsing_helper.wrong_path"
]
[2019-05-28T08:54:56.639Z] INFO sending __callback tx...
{
"contract_myid": "0x72fdf59adf3ecc92244e3b173ce1657252ab5eb877c3569a393599d34dd2c848",
"contract_address": "0x481a276d14a6a74e1ec1f74b64c2af226ba7033c"
}
[2019-05-28T08:55:01.853Z] INFO contract 0x481a276d14a6a74e1ec1f74b64c2af226ba7033c __callback tx sent, transaction hash: 0xfada229b6f9860e0717b3a098dd93aaef280852dbf75109c830b555c488e6c81
{
"myid": "0x72fdf59adf3ecc92244e3b173ce1657252ab5eb877c3569a393599d34dd2c848",
"result": "",
"proof": null,
"proof_type": "0x00",
"contract_address": "0x481a276d14a6a74e1ec1f74b64c2af226ba7033c",
"gas_limit": 200000,
"gas_price": null
}
Please help to solve this.
Thank you for adding the error logs.
Actual answer:
If you're adding POST data as a string but that's in a valid JSON format, it will be parsed as such. In order to preserve it as a string, you need to add a newline char or whitespace so the beginning of the string:
"\n<post-data-here"
Original answer re the
parsing-error
which proved not to be the main issue in the end...You're hitting a parsing error in the
ethereum-bridge
due to it trying but failing to parse the returnedjson
from your query.However at the time of writing, your local tunnel is returning a
404
error rather than the data it originally returned.Then, as the ethereum-bridge
attempts to parse the
jsonto pluck the value from the
a` key, per your query:json(https://purple-squid-54.localtunnel.me).a
...it can't because there is not
json
and so noa
field and so you get a parsing error.To fix it, ensure your local tunnel is working and that the data returned is in correct
json
format, and that there is ana
key present for the parser to work with.