Search code examples
androidandroidhttpclientandroid-json

How to send JSON Format HTTP Request to Server?


I am trying to send a HTTP Server request (JSON Encoded String) to server, but don't understand how to make the server request.

This is the format which gives me JSON response.

   {
"api_id": "Ddbl77c22oCVrXQs2WiZ",
"api_secret": "qjN9eEB9VVVKZm0PzKfqjN9eEB8",
"api_request": "login_user",
"data": {
    "user_name": "sampanchal2611@gmail.com",
    "user_type": "general",
    "password": "123456789",
    "device_id": "webdevdeid",
    "device_type": "test"
}

}


Solution

  • Create a data object (model) that will represent the data you want to send in your JSON.

    Then use a library like Retrofit to send your data to the server.