[英]How does url encoding/decoding work in web service calls
I need to consume a third party api which is expecting url as below 我需要使用需要以下网址的第三方api
URL?queryParam=02/10/1990 URL?queryParam = 02/10/1990年
when i am calling that api by appending queryParam(ab above) it is working fine. 当我通过附加queryParam(ab以上)调用该api时,它工作正常。
But when I call api as below 但是当我如下调用api时
GetMethod httpMethod = new GetMethod(url); GetMethod httpMethod =新的GetMethod(url); httpMethod.setQueryString(getNameValuePairs(requestParams));
httpMethod.setQueryString(getNameValuePairs(requestParams)); where requestParams is map of request params.
其中requestParams是请求参数的映射。 api is giving 400 error.
api给出400错误。
api I am using here is apache.common apis 我在这里使用的api是apache.common api
when I looked in setQueryString code,requestParams are url encoded. 当我查看setQueryString代码时,requestParams是url编码的。
so my doubts are. 所以我的疑问是。
A simple solution is to frame the uri and pass it to getMethod() constructor. 一个简单的解决方案是对uri进行框架化并将其传递给getMethod()构造函数。
string url;
url = baseURL+"?queryParam=02/10/1990" ;
GetMethod httpMethod = new GetMethod(url);
Query params are mostly used for post Request payload. 查询参数主要用于请求后的有效负载。 In your case , there's on need fo
在您的情况下,需要
Use base64 url encoding and decoding. 使用base64 url编码和解码。 It will solve the problem.
它将解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.