当前位置: 首页 > 知识库问答 >
问题:

400Spring错误请求错误

锺离阿苏
2023-03-14

我得到了这个错误,有什么想法会导致它吗?我试图发送一个DTO,它有一个扩展抽象类的对象列表,我想这个问题可能是因为DTO中的列表,还是因为抽象类的子类?

@Autowired
private RestClient restClient;


@Override
public ReceiptDto create_TicketIdentifier_For_Sale(TicketSaleDto tiDto)
        throws ServiceException {

    RestTemplate restTemplate = this.restClient.getRestTemplate();
    String url = this.restClient.createServiceUrl("/ticketIdentifier/");
    HttpHeaders headers = this.restClient.getHttpHeaders();
    //headers.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
    HttpEntity<TicketSaleDto> entity = new HttpEntity<>(tiDto, headers);

    ReceiptDto ti = null;
    try {
        ParameterizedTypeReference<ReceiptDto> ref = new ParameterizedTypeReference<ReceiptDto>() {};
        ResponseEntity<ReceiptDto> response = restTemplate.exchange(URI.create(url), HttpMethod.POST, entity, ref);
        ti = response.getBody();
        //  System.out.println(ti.getEntryDto().getReceiptDto().getCustomerDto().getLastname());
    } catch (RestClientException e) {
        e.getStackTrace();
        throw new ServiceException("Could not retrieve ticketIdentifiers: " + e.getMessage());
    }
    return ti;  
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Date: Sat, 13 Dec 2014 01:21:34 GMT[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Content-Type: text/html; charset=ISO-8859-1[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Cache-Control: must-revalidate,no-cache,no-store[\r][\n]"
2014-12-13T02:21:34,867 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Content-Length: 316[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "Server: Jetty(9.2.2.v20140723)[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "[\r][\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<html>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<head>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<title>Error 400 Bad Request</title>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</head>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<body><h2>HTTP ERROR 400</h2>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<p>Problem accessing /ticketline/ticketIdentifier/. Reason:[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "<pre>    Bad Request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</body>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.wire - http-outgoing-0 << "</html>[\n]"
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << HTTP/1.1 400 Bad Request
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Date: Sat, 13 Dec 2014 01:21:34 GMT
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Content-Type: text/html; charset=ISO-8859-1
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Cache-Control: must-revalidate,no-cache,no-store
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Content-Length: 316
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG http.headers - http-outgoing-0 << Server: Jetty(9.2.2.v20140723)
2014-12-13T02:21:34,868 [JavaFX Application Thread] DEBUG execchain.MainClientExec - Connection can be kept alive indefinitely
2014-12-13T02:21:34,868 [JavaFX Application Thread] WARN  client.RestTemplate - POST request for "http://localhost:8080/ticketline/ticketIdentifier/" resulted in 400 (Bad Request); invoking error handler
2014-12-13T02:21:34,868 [JavaFX Application Thread] WARN  client.RestTemplate - POST request for "http://localhost:8080/ticketline/ticketIdentifier/" resulted in 400 (Bad Request); invoking error handler
2014-12-13T02:21:34,870 [JavaFX Application Thread] DEBUG conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://localhost:8080] can be kept alive indefinitely
2014-12-13T02:21:34,870 [JavaFX Application Thread] DEBUG conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://localhost:8080][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2014-12-13T02:21:34,871 [JavaFX Application Thread] DEBUG controller.TicketingProcessController - Could not retrieve ticketIdentifiers: 400 Bad Request

共有1个答案

鄂伟兆
2023-03-14

解决方案在这里…子类的一些定义解决了我的问题…http://www.sureshpw.com/2013/09/javajson-polymorphic-mapping-using.html

 类似资料:
  • 我有一个基于Spring Web model view controller(MVC)框架的项目。Spring Web模型-视图-控制器(MVC)框架的版本是3.2.8 我有这个控制器 这个URL一切正常:

  • 目前从Angular JS controller中,我试图将JSON数据发送到后端服务。但是我有400个错误的请求错误。 在Controller中,我试图通过http服务发送数据,如下所示:

  • 我正在使用实现一个联系人应用程序。现在,我正试图通过发送以下格式的put请求来更新联系人 我将XML作为字符串发送,作为请求的主体。这是我的xmlString(请求主体) 我写了下面的代码来发送更新联系人的PUT请求。 当我试图在中发送请求时,联系人更新成功。但是当我试图运行上面的程序时,我得到了 400错误请求错误 我不知道我哪里出错了。任何帮助都将不胜感激!

  • 我正在尝试搜索亚马逊的产品广告,并使用botlenose来帮助我做到这一点。但是,我刚刚收到HTTP错误400。 其他一些重要信息: 我来自巴西,我的标签也来自亚马逊。这是个问题吗? 我确实检查了我的钥匙、秘密和标签,一切正常。我确实在StackOverflow上查看了其他一些问题,但对我来说没有任何效果。 当然,出于安全原因,我更改了密钥。 Traceback(最近一次调用最后一次):File"

  • 我正在为一个项目使用Hackerrank API。查看官方文档,点击这里! 在他们的网站上有一个使用UNIREST的例子, 由于我使用的是axios,所以我将其转换为类似的axios代码,如下所示: 我希望这只适用于示例中所示的示例,但它给我带来了以下错误: 请求失败,状态代码为400 错误:请求失败,状态代码为400 在createError(createError.js:16) 在sett(s

  • 我正在尝试从访问代码中获取访问令牌。但存在 400 错误请求错误的错误 我正在使用此链接获取访问代码 https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 响应此链接,我正在获取查询字符串中的代码,返回 URL 代码=Mh12d04c8