问号?在jax-rs球衣中被%3F取代

问题描述

在jax-rs jersey中调用API时,我必须传递一个参数。但这正转换为某些特殊字符。 我已经声明了一个变量mcopy,它在某些情况下可能为false或true。 我的URI是

URI:- https://idcs-oda-xxxxxxx.com/api/v1/bots/pushRequests?copy=true

我的代码

Response rawres = client.target("https://idcs-oda-xxxxxxx.com")
                                .path("bots")
                                .path("pushRequests?copy="+mcopy")
                                .request().header("Authorization",access_token)
                                .post(null,Response.class);

它引发错误

  https://idcs-oda-xxxxxxx.com/api/v1/bots/pushRequests%3Fcopy=false,status=404,reason=Not Found

实际上pushRequests?copy=mcopy被转换为pushRequests%3Fcopy=false

我如何保留?是符号吗?

解决方法

您没有正确使用API​​。您想这样做:

Response rawres = client.target("https://idcs-oda-xxxxxxx.com")
                                .path("bots")
                                .path("pushRequests")
                                .queryParam("copy",mcopy) // this is the change
                                .request().header("Authorization",access_token)
                                .post(null,Response.class);