我正在将Apache Camel与XML DSL结合使用以使用和公开REST服务。
我有一个请求正文{"name":"your name","phonenumber":"111-111"}
我成功地能够直接发送此json请求正文,并从使用的端点URL获得成功的响应。而当我浏览公开的URL时,出现以下异常。
org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking
<!--Consumed URL--> with statusCode: 400 /n responseBody:
{"timestamp":"2020-04-07T06:15:41.302+0000","status":400,"error":"Bad Request",
"message":"Required request body is missing: public boolean
com.agcs.cids.BookingRestController.createBooking(org.bson.Document...)","path":"-----"}
在调用URL之前,我什至可以成功打印正文。请在下面对我的代码进行罚款:
<log loggingLevel="TRACE" message="Request from source: Body: ${body}" />
<log loggingLevel="TRACE" message="Request from source: Header: ${headers}" />
<to uri="restlet:<--Consumed URL-->?restletMethod=POST" />
答案 0 :(得分:0)
我想您的代码正在尝试-
POST
JSON正文中发送{"name":"your name","phonenumber":"111-111"}
请求。在这种情况下,您可能想重新访问代码并验证是否正确设置了主体,例如<setBody>
和<to>
标记内正确使用了<from>
。 POST
请求中发送到不接受JSON
正文的URL。您是否尝试过将"Accept", "application/json"
添加为标题?<from>
和<to>
地址(您提到“ Consumed URL”,在<to>
端点的情况下,语义上应为“ Consuming URL” )