Android Volley如何在正文中同时发送带有身份验证标头和Json对象的请求

问题描述:

我需要通过凌空发送带有身份验证标头和正文中的Json对象的http请求. Bu我没有在齐射中找到要求.

I need to send via volley a http request with both authentification header and Json object in body. Bu I did not found a request for this in volley.

我找到了GsonRequest和JsonObjectRequest. GsonRequest int方法,字符串url,类clazz,地图标题,侦听器,ErrorListener错误侦听器,Gson useGson)

I found GsonRequest and JsonObjectRequest. GsonRequest int method, String url, Class clazz, Map headers, Listener listener, ErrorListener errorListener, Gson useGson)

JsonObjectRequest (int方法,java.lang.String url,JSONObject jsonRequest ,Response.Listener侦听器,Response.ErrorListener errorListener)

JsonObjectRequest (int method, java.lang.String url, JSONObject jsonRequest, Response.Listener listener, Response.ErrorListener errorListener)

知道要做什么吗?

在您的Request类中,覆盖getHeaders()以发送自定义标头

In your Request class, override getHeaders() to send custom Headers

要在请求正文中发送参数,您需要覆盖其中一个 请求类的getParams()或getBody()方法

To send parameters in request body you need to override either getParams() or getBody() method of the request classes

在这里描述:

使用Volley的Android中的异步HTTP请求