我已经使用了 OKHtttpClient 包。需要在 Post 方法中提交数据,并且 mediatype 应该是 x-www-form-urlencoded
'''
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType,
"firstname="+fname+"&surl="+surl+"&phone="+phone+"&hash="+Hash+"&txnid="+txnid+"&productinfo="
+productinfo+"&amount="+amount+"&email="+email+"&curl="+curl+"&furl="+furl+"&key="+key1+"&pg="
+pg+"&bankcode="+bankcode+"&mode="+mode+"&vpa="+vpa+"");
Request request = new Request.Builder()
.url("https://secure.payu.in/_payment")
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
'''
我努力了 :
HttpRequest<?> req = HttpRequest.POST(new URI(payPath),data).contentType(MediaType.APPLICATION_FORM_URLENCODED);
Flowable flowable = httpClient.retrieve(req, String.class);
return (Maybe<String>) flowable.firstElement();