java—如何在micronaut框架中编写此代码

eulz3vhy  于 2021-07-16  发布在  Java
关注(0)|答案(0)|浏览(237)

我用过OkhttpClient包,需要用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();

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题