【问题标题】:Postman get request with multiple queryparams with the same key returns empty list具有相同键的多个查询参数的邮递员获取请求返回空列表
【发布时间】:2020-03-20 15:59:53
【问题描述】:

我正在尝试获取与我的研究标准相对应的所有产品的列表值,在我的案例中,研究标准是使用 Postman (GET METHOD) 的参考和区域:

https://localhost/services/choices/?ref=test1&ref=test2&region=west

但每当我尝试在我的代码中获取我的引用时,我都会收到一个大小为零的列表。

@Path("/choices")
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "get products")
@ApiResponses(value = {@ApiResponse(code=200,message = "Success"),
        @ApiResponse(code=500, message = "Server error")
})
public Response getProduct(@QueryParam("ref") final List<String> ref,
                           @QueryParam("region") final String region,
                          @Context final HttpServletRequest request){
    LOGGER.info("Call for references {} and region {}",ref,region);
    try{


        return Response.ok(productBusinessService.getProducts(ref,region)).build();

    }catch (Exception e){

        throw new InternalServerErrorHttpException("Technical Error", e.getMessage(), e);
    }finally {
        LOGGER.info("End of the Call for references {} and region {}",ref,region);
    }
}

我的问题是:是否可以在邮递员中传递具有相同键名的多个查询参数,如果可以,为什么我在获取区域值时收到空列表

【问题讨论】:

  • 如果您尝试使用 curl 访问 api 会发生什么?
  • 我不认为这是邮递员的问题。我做了完全相同的服务,它的多参数工作

标签: java postman query-parameters queryparam


【解决方案1】:

实际上,我必须重新启动我的邮递员客户端才能使其工作,因此重新启动客户端可以作为解决方案

【讨论】:

    猜你喜欢
    • 2017-08-11
    • 2019-04-25
    • 1970-01-01
    • 2014-11-27
    • 2019-09-19
    • 1970-01-01
    • 2021-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多