JAVA gRPC request error to DAML Hub

I have the IOU sample app deployed to DAML Hub and am trying to use the Java app to interact with it. I am getting a error of “io.grpc.StatusRuntimeException: PERMISSION_DENIED: An error occurred. Please contact the operator and inquire about the request ” when it tries to make this request

client
.getActiveContractSetClient()
.getActiveContracts(iouFilter, true)
.blockingForEach(
response → {
response
.getOffset()
.ifPresent(offset → acsOffset.set(new LedgerOffset.Absolute(offset)));
response.getCreatedEvents().stream()
.map(Iou.Contract::fromCreatedEvent)
.forEach(
contract → {
long id = idCounter.getAndIncrement();
contracts.put(id, contract.data);
idMap.put(id, contract.id);
});
});

I am connecting as is suggested in another post and it is connecting fine -

DamlLedgerClient client =
DamlLedgerClient.newBuilder(ledgerhost, ledgerport)
// use the roots of trust already present on the system,
// ledgers running on *.daml.app domains use certs
// provided by Let’s Encrypt
.withSslContext(GrpcSslContexts.forClient().build())
// on Daml Hub, you will still need an access token;
// it can be supplied here or per operation
.withAccessToken(accessToken)
.build();

My thought is maybe I need to pass the access token on the request as well? I am not finding in the documentation how to try that though.

Hi @RyanMedlen,

I just tested using the Iou sample app on Daml hub using your modifications and it works fine for me.

What I suspect is happening is that you are running as party Alice which is the default in the sample app. Daml hub on the other hand allocates different party identifiers so your token is for a different party than Alice and your request fails.

To fix that you can edit the party in pom.xml or pass it directly on the command line, e.g.

mvn compile exec:java@run-quickstart -Dparty=ledger-party-youruuidhere

You can find your actual party id in the Daml hub console where you also got your access token.

4 Likes

That was exactly it. Thanks for the help.

3 Likes