This is my Json body :
{
"username": {
"country": "IN",
"number": "9620494812"
},
"password": "119209"
}
I'm trying to make a POST request with Okhttp
as follows:
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();
I have checked the request but i still get the error as
Response is :
{"status":401,"type":"about:blank","title":"Unauthorized"}
What am I doing wrong here?