How to receive PUT-request in REST Services?

0
When I create a microflow "PutIssue" that is registered as follows: MicroflowName: 'MyFirstModule.PutIssue' SecurityRole: '*' Description: 'Modify an issue' PathTemplate: 'issue/{id}' HttpMethod: PUT How can I allow a body to be sent along with the request? I want to send the "Issue" in JSON format in the body of the request. My microflow should be able to deserialize the JSON (or have it done automatically by Mendix) so I can use the Issue object that was sent by the user. I can receive the "id"-parameter fine. But when I add an argument of type "Issue" to the "PutIssue" microflow, I get "An exception occurred while running the after-startup-action": com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: Cannot publish microflow MyFirstModule.PutIssue, it should exist and have exactly zero or one argument at RestServices.CreateMicroflowServiceWithPath (JavaAction : 'Call 'StartMicroflowServiceJava'') at MyFirstModule.StartUp (SubMicroflow : 'Call 'CreateMicroflowServiceWithPath'') Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(SourceFile:158) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: Cannot publish microflow MyFirstModule.PutIssue, it should exist and have exactly zero or one argument at com.mendix.core.component.InternalCore.execute(SourceFile:274) Caused by: com.mendix.core.CoreRuntimeException: java.lang.IllegalArgumentException: Cannot publish microflow MyFirstModule.PutIssue, it should exist and have exactly zero or one argument at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:216) Caused by: java.lang.IllegalArgumentException: Cannot publish microflow MyFirstModule.PutIssue, it should exist and have exactly zero or one argument
asked
3 answers
0

I'm not entirely sure if you are consuming or publishing a rest service. As you are using httpmethod put I would say consume, but on the other hand you mention you want to receive data. Plus your stacktrace implies publishing.

From the stacktrace:

Cannot publish microflow MyFirstModule.PutIssue, it should exist and have exactly zero or one argument

Did you try to only have the issue entity as microflow parameter?

answered
0

Hi Henry,

It is perfectly possible to use multiple values as input for an argument, however, you should wrap those values in one single transient object. So if you create a domain model transient entity:

MyArgs
------
issueid : integer
issue : string
reason : string

Your microflow should then have one argument of the type MyArgs. After that you are free to mix and match stuff from the url and the document body.

You could for example use an url like /submitissue/{id} and send json body { issue : string, reason : string }, but you could also use a template /submitissue/{id}/{issue} with { body : reason } or no body at all.

answered
0

I tried doing this, however, this is the only way I could get it to work.

As you can see I have to specify the IssueViewIdWrapped_IssueView relationship in the body payload. Is there a way I can get this to work when I only supply the "Issue"-entity in the body?

alt text

answered