1

I am running a testrpc instance combined with Ethereum Bridge. Upon calling the smart-contract function "purchaseLogo" using Metamask (and web3), 2 oraclize_queries are getting initiated and make a GET-Request to my Node.js server (localhost). I get the following Error:

ERROR HTTP query error
[
"LocationParseError",
"parsing_helper.wrong_path"]

How can I resolve this HTTP query error? I can't find a solution right now. Could someone point me into the right direction? The endpoint works well when testing it in the browser. Thanks in advance!

My Smart Contract code looks like this:

pragma solidity ^0.4.0;

import "./usingOraclize.sol";


contract Purchasing is usingOraclize {

    string[] public subIDsBought;
    uint256 public price;
    string public query1;
    string public query2;
    address public author;
    address public buyer;
    uint256 public sentValue;
    bool public lastTransactionWasValid = false;

    mapping (bytes32 => uint) queries;

    event newOraclizeQuery(string description);

    //Setup:
    //node bridge -H localhost:8545 -a 1

    function Purchasing () public {
        OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
        oraclize_setNetwork(networkID_testnet);
    }

    function __callback(bytes32 myid, string result) {
            if (msg.sender != oraclize_cbAddress()) throw;


       if (queries[myid] == 1){
          author = parseAddr( result );

       } else{
           if(queries[myid] == 2){
                price = parseInt(result);

               //Last query, transfer to authorwallet
               if (sentValue >= price) {
                   //Transfer to author - success
                   lastTransactionWasValid = true;
                   author.send(sentValue);
               } else {
                   //Transfer back to buyer - failure
                   lastTransactionWasValid = false;
                   buyer.send(sentValue);
               }

           } 
       }
    }

    function purchaseLogo( string subID ) public payable returns (bool success) {

            buyer = msg.sender;

            query1 = strConcat("json(", "http:localhost:3000/api/getpurchasedata/", subID, ")", ".purchase.recipient");
            query2 = strConcat("json(", "http:localhost:3000/api/getpurchasedata/", subID, ")", ".purchase.price");

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

            //oraclize_query("URL", query);
            queries[oraclize_query("URL", query1)] = 1; // ask for recipientWallet
            queries[oraclize_query("URL", query2)] = 2; // ask for price

            return     lastTransactionWasValid;
    }


    //Helper functions to concatenate strings in solidity
    function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string){
        bytes memory _ba = bytes(_a);
        bytes memory _bb = bytes(_b);
        bytes memory _bc = bytes(_c);
        bytes memory _bd = bytes(_d);
        bytes memory _be = bytes(_e);
        string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
        bytes memory babcde = bytes(abcde);
        uint k = 0;
        for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
        for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
        for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
        for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
        for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
        return string(babcde);
    }

    function strConcat(string _a, string _b, string _c, string _d) internal returns (string) {
        return strConcat(_a, _b, _c, _d, "");
    }

    function strConcat(string _a, string _b, string _c) internal returns (string) {
        return strConcat(_a, _b, _c, "", "");
    }

    function strConcat(string _a, string _b) internal returns (string) {
        return strConcat(_a, _b, "", "", "");
    }

}

1 Answer 1

1

One definite culprit is that you are doing a query to localhost. Oraclize is a remote service, and thereby when you query localhost, you are querying localhost on whatever remote machine Oraclize have your query running on, not yours.

You can use something like https://localtunnel.github.io/www/ to expose whatever you have running locally, to be remotely available, and then Oraclize will be able to query it successfully, pending an update of the query target.

It may be faster for you to prototype queries using this page: http://app.oraclize.it/home/test_query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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