问题描述
我正在尝试将curl请求转换为截击,但我得到com.android.volley.AuthFailureError
,我已经尝试了所有堆栈溢出答案,但没有帮助,如果有人帮助我在做什么,我将非常感谢错误的。
卷曲:curl -X POST "http://API_ADDRESS/api/v1/Account/Login" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"username\": \"string\",\"password\": \"string\"}"
转换为截击:
StringRequest postRequest=new StringRequest(Request.Method.POST,login_post_url,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("ABC:",response);
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("ABC",volleyError.toString());
}
}){
@Override
public Map<String,String> getParams() {
Map<String,String> params= new HashMap<>();
params.put("username","app");
params.put("password","tty_TTY_2020");
return params;
}
@Override
public Map<String,String> getHeaders() {
Map<String,String> headers= new HashMap<>();
headers.put("accept","application/json");
headers.put("Content-Type","application/json");
return headers;
}
};
queue.add(postRequest);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)