【问题标题】:How to pass json of 6800 characters in web service?如何在 Web 服务中传递 6800 个字符的 json?
【发布时间】:2019-05-16 10:14:45
【问题描述】:

我用 Java 编程,我使用运动衫

我想将由 6800 个字符组成的 json 传递给我的网络服务

最初我把它作为一个查询参数,但它没有工作。 然后我用 HeaderParam 进行更改,但它还不起作用。 我该怎么办?

@Path("InsertSconti")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String InsertCustomer(@HeaderParam("token") String token,@QueryParam("customer") String customer)
{

http://localhost:8087/clayapi/restservices/InsertCustomer?customer=json(6800 个字符)

它给了我错误 400 Bad Request

【问题讨论】:

标签: json rest web-services


【解决方案1】:

使用Requestparam

我是这样用的

@RestController
    public class OutlookController {
    @RequestMapping(value="/api", method=RequestMethod.POST)
    @ResponseStatus(value = HttpStatus.OK) 
         public String pushNotification(@RequestParam(required = false, value = "code") String code) {
           System.out.println("yes done");
            System.out.println(code);
                        return "sai";
        }
}

curl -X POST -d {code:"hhhhh"} http://localhost:8080/api

在“-d”之后在上面的 curl 中给客户 json。 如果您使用邮递员或肥皂 UI 来测试您的服务,请在请求正文中提供 json。

这将允许您提供超过 6800 个字符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-15
    • 1970-01-01
    • 2017-01-02
    相关资源
    最近更新 更多