这是我的Json身体:
{
"username": {
"country": "IN",
"number": "9620494812"
},
"password": "119209"
}
我尝试使用Okhttp
发出POST请求,如下所示:
Username username = new Username("IN" , "9620494812");
JSONObject postData = new JSONObject();
try {
postData.put("username" , username);
postData.put("password" , "119209");
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(MEDIA_TYPE , postData.toString());
Request request = new Request.Builder().url("https://www.gruppie.in/api/v1/login")
.method("POST" , body).build();
我已检查过请求,但我仍然收到错误
回应是:
{"status":401,"type":"about:blank","title":"Unauthorized"}
我在这里做错了什么?
答案 0 :(得分:4)
根据您的JSON,您必须发送UpdateSourceTrigger
这样的请求。试试这个
JSON