Home Rest function fails before the start
Reply: 1

Rest function fails before the start

Gangnus Published in 2017-12-07 08:27:54Z

Making API Rest testing, sometimes I meet with a situation, when a Rest function fails, but even the first breakpoint in it is not reached. Obviously, some preliminary settings fail. But what exactly?

Here is the header of the function:

@RequestMapping(value = { "/export" }, method = RequestMethod.POST, produces = "text/plain;charset=UTF-8")
public Object exportConfiguration(@RequestBody ConfigurationExport configurationExport) {
    try {
        // at return here stands the breakpoint that is never reached:
        return configurationExporterProvider.export(configurationExport);

The body of request is:


As a response I am getting:

            <td>HTTP ERROR: 415 Unsupported Media Type
                <p>Problem accessing /cc/api/configuration/export
                    <pre id="message">Unsupported Media Type</pre>

OK, thought I - something happens when trying to load the body into configurationExport. But there is no throwing errors in that class constructor:

private ConfigurationExport() {
    documentTypes = new ArrayList<>();
    valueSets = new ArrayList<>();
    configuration = new Configuration();

And setters and getters created by Lombok. And Lombok, surely, does not know anything about any Media Types.

I agree with application returning me the response with an error message. But where does it appear? Where and how should I look for it?

tkruse Reply to 2017-12-08 04:05:12Z

Before your method is called, Spring performs several Validations of the request, and the request headers. You can set a breakpoint in the Spring class method org.springframework.web.servlet.DispatcherServlet.doDispatch() to debug that, if you need.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.362289 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO