Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sophia.api.getReceivedDocuments not working #2

Open
laurencehardmanarktree opened this issue May 15, 2019 · 0 comments
Open

sophia.api.getReceivedDocuments not working #2

laurencehardmanarktree opened this issue May 15, 2019 · 0 comments

Comments

@laurencehardmanarktree
Copy link

laurencehardmanarktree commented May 15, 2019

Configuration

sophiatx-alexandria-api version 1.0.18
node --version 8.15.1

Context

Within express.js application

Description

When posting custom JSON to a specified address, say 'arktree1', using something like the below:

/* POST to /json */
router.post('/json', function (req, res, next) {
    sophia.api.makeCustomJSONOperation(20646, 'arktree2', ['arktree1'], JSON.stringify(req.body), '<REDACTED PRIVATE KEY>', function(err,response){
        console.log(response);
        console.log(err);
        res.json(response);
    });
});

A suitable response is returned, indicating that the data was successfully transmitted:

{
    "ref_block_num": 60381,
    "ref_block_prefix": 4108162935,
    "expiration": "2019-05-15T07:17:12",
    "operations": [
        [
            "custom_json",
            {
                "fee": "0.010000 SPHTX",
                "sender": "arktree2",
                "recipients": [
                    "arktree1"
                ],
                "app_id": 20646,
                "json": "{\"some-key\":\"some-val-26042019\",\"anotherKey\":\"another-val-15052019\"}"
            }
        ]
    ],
    "extensions": [],
    "signatures": [
        "<REDACTED>"
    ],
    "transaction_id": "df69a1f7c172c65ac04b8e2b8dc08e4df433e1fa",
    "block_num": 6679519,
    "transaction_num": 0
}

However, when using the sophia.api.getReceivedDocuments method as below:

/* GET Documents sent to 'arktree1' */
router.get('/documents', function(req,res,next) {

  sophia.api.getReceivedDocuments(20646, 'arktree1', 'by_recipient', '2018-10-06T09:35:13.85251Z', '1000', function(err,response){
     console.log(err,response);
     res.json(response);
  });
});

Only 1 result is returned:

{
    "app_id": 20646,
    "binary": "false",
    "recipients": "arktree1",
    "sender": "arktree1",
    "data": "{\"owner\":\"Rooibos\",\"rfid\":7040281458,\"grade\":\"20\",\"weight\":125,\"locations\":[{\"name\":\"Shed\",\"owner\":\"Rooibos\",\"accepted\":\"2019-01-10 20:13:20\"},{\"name\":\"Delivery Truck (BKB 001 EC)\",\"owner\":\"BKB\",\"accepted\":\"2019-01-10 20:13:21\"}]}",
    "received": "2019-01-10T19:46:57"
}

It is expected to return the first 1000 results sent to arktree1 starting from the specified date/time - which should include the documents we have just sent using sophia.api.makeCustomJSONOperation, however only 1 document is returned - and is not related to the data we just posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant