0
function getRandomNumber() public payable {
    require(msg.value >= 0.000175 ether); // 175,000 gas * 1 Gwei = 0.000175 ETH

   bytes32 queryId = oraclize_query("URL", "json(https://jsonplaceholder.typicode.com/posts).title", "{title: 'foo',body: 'bar',userId: 1}");

//   oraclize_query( 
//       "nested", 
//       "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"data\"]', '\\n{\"jsonrpc\": \"2.0\", \"method\": \"generateSignedIntegers\", \"params\": { \"apiKey\": \"00000000-0000-0000-0000-000000000000\", \"n\": 1, \"min\": 1, \"max\": 1000, \"replacement\": true, \"base\": 10 }, \"id\": 14215 }']"
//     );   

    LogOraclizeQuery("Oraclize query was sent, standing by for the answer..");

    validIds[queryId] = true;
}

When I try to use the first query it doesn't work and the result is not updated but the commented one works just fine. I don't know whats wrong with it.

This the callback function

    function __callback(bytes32 queryId, string result, bytes proof) public {
        require(msg.sender == oraclize_cbAddress());

        require(validIds[queryId]);

        // randomNumber = parseInt(result); 

        title = result;

        LogResultReceived(result); 

        validIds[queryId] = false;
}
0

Try this

json(https://jsonplaceholder.typicode.com/posts).0.title

Also, you can test your queries here: https://app.provable.xyz/home/test_query

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.