REST API calls using http-connector not working

I am trying to POST to a simple REST endpoint using Camunda and pass a String, but cannot seem to make it work.

Here is my spring boot controller -

@PostMapping(value=“/pie/test”)
public void test(@RequestBody String eventMessage) {
System. out .println("Here is the test String from Camunda: "+eventMessage);
}

Here is my modeller -

Here is how I am POSTing using insomnia to the Camunda start endpoint and getting a response

But the problem is, Its not sending the String to the controller. I am seeing this exception in the controller console log -

2019-05-30 16:47:05.116 WARN [PIE,5cf04149bdeeeb771519484aef6e7abc,1519484aef6e7abc,true] 9524 — [nio-8090-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public void com.pie.controller.PieController.test(java.lang.String)]

Why would it not accept the String as the RequestBody? Any help would be appreciated!!

Any help would be appreciated. Can someone please respond?

@shkrish @cyberatl1 anyone?

try string instead of String

@shkrish: Still didnt work. Same error :frowning:

@suryamukerjee,

Based on the error you’re seeing, my guess is that you haven’t set your payload correctly. Try using ${eventMessage}. Also, if you’re including a Content-Type of application/json in your headers map, you probably should be sending along JSON. I’m not sure how picky Spring Boot’s RESTful Web Services tool is from that perspective…

-Ryan

@ryans58: Thanks for your response Ryan. Could you please elaborate on ${eventMessage}? I did not quite get it. I am just trying to send a string in the payload

@suryamukerjee,

If you specify ${eventMessage} as the value for payload, it will send the value you specify when you start the process instance - given your example from earlier in this thread - over to your REST endpoint. Here’s a simple example, in this case using a variable named “jsonRequest”:

-Ryan