Rest api like tctl workflow start

I am creating a rest endpoint that will do work like tctl workflow start tctl workflow start | Temporal Documentation

Rest endpoint accepts json payload and the workflow name and it should invoke the workflow.

I am not sure how to pass the json input as parameter to the stub. I want this endpoint to be generic so you can invoke different workflows with different input payloads, hence I do not want to instantiate any particular class from the json payload.

WorkflowStub workflowStubById = client.newUntypedWorkflowStub(workflowname, workflowOptions);

workflowStubById.start(what goes in here??);

You could pass the Json as String input, or JsonNode would work as well.
Other options could be to write a custom “wrapper” class that holds your rest endpoint input that is common to all workflows, see for example WorkflowData in java DSL sample, or you could use something like CloudEvents as a standard event format and write a custom payload converter like it is done in this sample.

I would recommend creating the Payloads structure directly and then writing your custom DataConverter to pass it as it is. I filed an issue to get this added to the default DataConverter.

Passing raw json string indeed does not work.

@maxim I am not sure what you mean. Are you saying I need to instantiate the particular class file/object and pass it as parameter instead of some generic string until linked issue is resolved?

Temporal internally passes data as Payloads protobuf. DataConverter implementations are responsible for converting arguments to Payloads. So a pass through DataConverter implementation would allow directly creating Payloads instance that matches a destination activity/child workflow signature.