Error when calling the com.daml.ledger.api.v1.CommandSubmissionService.Submit via grpcurl command line

Hi,
We are facing an issue when calling the Ledger API using Grpcurl from command line.
We are trying to submitting the json payload using grpcurl command and we are getting the error back whereby we feel that we are passing the right value in that field.
And I can confirm that this same workflow works when we sumbit the same vales using grpc java code

Error we are getting is below

ERROR:
Code: InvalidArgument
Message: Invalid field module_name: Expected a non-empty string

Command used

cat /tmp/1630912503091.json | grpcurl -d @ -plaintext localhost:8080 com.daml.ledger.api.v1.CommandSubmissionService.Submit

Have anyone tried publishing the content via grpcurl command line to ledger ?

Can you share the JSON payload you used? It looks like the format isn’t quite right. You can definitely submit commands via grpcurl.

Its not allowing me to upload the json

I get below error

How large is it? You could just copy/paste it in a code block (between triple backticks).

I’d say first start would be to look at your module_name reference, and see why it’s being interpreted as missing. Either missing or in the wrong place?

Perhaps start with a simple example (from DAML SDK, running on Sandbox) so you have a validated grpcurl call that submits a call successfully. That will help you to see where your problem is, which is no doubt a misaligned message structure.

Alternatively put it in a Github gist or something and link that here.

I have updated to json to only have required information and have removed the content of fields array

command used to submit
cat sample.json | grpcurl -d @ -plaintext localhost:8080 com.daml.ledger.api.v1.CommandSubmissionService.Submit

{
“commands”: {
“ledger_id”: “devledger”,
“application_id”: “ledger-tool”,
“command_id”: “my-command”,
“party”: “20056”,
“commands”: {
“create”: {
“template_id”: {
“package_id”: “001b2786d536b8c2cfd190dd1a109d95922d9b3e313b7bbfb1feb4c0ddd565be”,
“module_name”: “DA.ASX.Main.Integration.BMW.Ingress”,
“entity_name”: “BmwIngressMaster”
},
“create_arguments”:
{
“fields”: [{
“label”: “message”,
“value”: {
“record”: {
“recordId”: {
“packageId”: “001b2786d536b8c2cfd190dd1a109d95922d9b3e313b7bbfb1feb4c0ddd565be”
},
“fields”: [{
}]
}
} }
]
} }
}
}
}

The issue is in your record id:

“recordId”: {
  “packageId”: “001b2786d536b8c2cfd190dd1a109d95922d9b3e313b7bbfb1feb4c0ddd565be”
},

You are specifying the package id but you’ve omitted the module_name and the entity_name. Omitting a string in protobuf is equivalent to setting it to an empty string so you get an error because module_name is empty.
You have two options for fixing that:

  1. Omit recordId completely. It’s optional on the gRPC API.
  2. Keep it but add the module and entity name. I can’t tell you what the correct ones here are (since you haven’t shared that code) but they correspond to the type of the message field of the BmwIngressMaster

Thanks @cocreature the error gone, below is the json I have modified and we are getting new error ?
Is there any specific syntax we need to follow ?

ERROR:
Code: InvalidArgument
** Message: Command interpretation error in LF-DAMLe: Expecting 3 field for record dcefc5335494ef4815997d46788e55e4c63c416ef3b3dd457d7df76b2c1cf7c5:DA.ASX.Main.Integration.BMW.Ingress:BmwIngressMaster, but got 1. Details: N/A.**

{
  "commands": {
    "ledger_id": "devledger",
    "application_id": "security-ledger-tool",
    "command_id": "my-command",
    "party": "20056",
    "commands": {
      "create": {
        "template_id": {
          "package_id": "dcefc5335494ef4815997d46788e55e4c63c416ef3b3dd457d7df76b2c1cf7c5",
          "module_name": "DA.ASX.Main.Integration.BMW.Ingress",
          "entity_name": "BmwIngressMaster"
        },
        "create_arguments": 
{
"fields": [{
"label": "message",
    "value": {
      "record": {
        "recordId": {
          "packageId": "dcefc5335494ef4815997d46788e55e4c63c416ef3b3dd457d7df76b2c1cf7c5",
		  "module_name": "DA.ASX.Main.Integration.BMW.Ingress",
          "entity_name": "BmwIngressMaster"
        },
    "fields": [{...........

I don’t know the definition of BmwIngressMaster but it sounds like it’s a template with 3 different fields. You are only specifying a single message field which is why you’re getting the error. I recommend checking the definition of the template to see which fields it has.