Back to an evergreen topic: can Postman be used to interact with the ledger (gRPC) API?

Previously, there were reports about a Postman bug which prevented Postman from being used to interact with the ledger (gRPC) API, via server reflection.

Then there were reports about the bug having been fixed.

Now as I try to use Postman (Version 10.24.7) against the ledger API, I can see the following:

  1. Server reflection seems to work fine, in as much as the dropdown menu contains the list of the API services.
  2. Getting the ledger id works fine.
  3. While trying to get the active contracts for a party, I get an “invalid argument” error, although the equivalent gRPCurl command works fine.

The service chosen in the dropdown menu in Postman:

ActiveContractsService/GetActiveContracts

Message body:

{
    "ledgerId": "bvzgeb91p8gq6cms",
    "filter": {
        "filtersByParty": [
            {
            "key":"ledger-party-85c0386e-f014-4a0c-80f3-58c7e1ea361b::1220a8af397e1f38697d7109d5e999e71cd341b1b71cf5cb88100e9a7cbc0660b971"
            }
        ]
    }
}

JWT is valid.

The answer:

INVALID_ARGUMENT(8,d54ddcc4): The submitted command has invalid arguments: filtersByParty cannot be empty

The equivalent gRPCurl command (copied from the Daml Hub docs) works fine:

TOKEN="XXX"
LEDGER_ID=bvzgeb91p8gq6cms
LEDGER_DOMAIN=bvzgeb91p8gq6cms.daml.app
DAML_LEDGER_PARTY=ledger-party-85c0386e-f014-4a0c-80f3-58c7e1ea361b::1220a8af397e1f38697d7109d5e999e71cd341b1b71cf5cb88100e9a7cbc0660b971

grpcurl -H "Authorization: Bearer $TOKEN" \
    -d "{\"ledgerId\":\"${LEDGER_ID}\", \"filter\":{\"filtersByParty\":[{\"key\": \"${DAML_LEDGER_PARTY}\"}]}}" \
    "${LEDGER_DOMAIN}:443" com.daml.ledger.api.v1.ActiveContractsService/GetActiveContracts

Is there still a bug in Postman, god forbid in Canton, or I am doing something wrong?

1 Like

Likely a bug in Postman. Generally grpcurl is the way to go when interacting with the gRPC services, as it is built for that. Postman was tailored to http restful-apis, and only added gRPC support later, and the gRPC support is likely to lag in that product.

Another useful one for browsing the grpc interfaces is grpcui — the command line interface to this is very similar to grpcurl, but it gives you a browser based interface to see the various groc services and required payload for each GitHub - fullstorydev/grpcui: An interactive web UI for gRPC, along the lines of postman

2 Likes

Thank you!

FWIW this query works for me in Postman:

{
    "filter": {"filters_by_party": {"Alice::1220887aa5ccf52d4f40bce8c132db99fa87c63b2f0bf0809b63592b5aa8e3ccb3e8":{"inclusive":{"template_ids": [{"package_id" : "d3a8a18f73f71026ca42ccefcc466e01cee6706a0408d01c96c6af84a6dfd817","module_name": "Main", "entity_name": "Asset"}]}}}},
    "ledger_id": "sandbox",
    "verbose": true
}

Albeit using Sandbox.

1 Like

Ah yes looks like Postman does support gRPC now

Likely need to add the use token as a bearer header to get this to work for an auth’d remote ledger then

1 Like

To provide anyone else who sees this with options:

That didn’t work for me for some unknown reason, but the following worked, so thank you for the hint:

{
    "filter": {
        "filters_by_party": [
            {
                "key":"ledger-party-30a2c552-a904-4725-a841-1667ea9e4448::1220564ea370a7ef9650929f7cb780aac36416d0fcd1e22f4be0806ee5ca6a060724",
                "value": {
                    "inclusive": {
                        "template_ids": [
                            {
                                "package_id": "d12686a437954ad403499d07662bc607752ce671cb2437805def29589cc894f6",
                                "module_name": "Main",
                                "entity_name": "Asset"
                            }
                        ]
                    }
                }
            }
        ]
    },
    "ledger_id": "dnafeidtzwihod5v",
    "verbose": true
}

Note to myself: RTFM, this is where I should’ve been looking: Ledger API Reference — Daml SDK 2.8.3 documentation.

Yes, I added the token to Postman, there was a problem with the request body JSON, but now it works. Thank you for looking into this!