Problem in Using Multipart Data in Microservice in Yaas
For now multipart data is not explicitly supported in yaas. But you can follow the tutorial to use it in your microservice. But I met a small problem in using it. What I expected is there is only one post method is automatically generated in the default resource file, which only has one final YaasAwareParameters yaasAware parameter. But actually there is another post method which also need a application/json part as the post body.
Let’s double check our api.raml file and you can see we only accept the multipart as the post body. How could the wrong method be generated?
Actually this is quite a tricky problem. The second is automatically generated because of the 23th row in the last screenshot. When you say the type of an endpoint is collection, then it will be treated like a normal entity and a new data could be posted into the collection via application/json format.
Easy way to solve this problem is just remove this line. Before doing mvn clean install don’t forget to remove the unnecessary post method in your default resource file. Then you will see everything is ok now.
But as we know the rules endpoint is truly a collection, why no problem occurred after the type line is removed? Because when we invoke the get method to query the rules collection, the collection is returned in an entity, and the entity could be transformed into a collection like List<Rule> list = response.readEntity(List.class);