Kotlin Android Webservice - PART 1
All the data is stored on a web server. To get this data into your app you need to establish a connection and communicate with the server on the internet.
Requests are made to RESTful web services in a standardized way via URIs. An URI (Uniform Resource Identifier) identifies a resource in the server by name, without implying its location or how to access it. For example, in the app for this lesson, you retrieve the image urls using the following server URI (This server hosts all Data Required):
A Uniform Resource Locator (URL) is a URI that specifies the means of acting upon or obtaining the representation of a resource, It specifying both its primary access mechanism and network location.
Sending Web service request
Here Each web service request contains a URI, and it is transferred to the server using the same HTTP protocol that's used by web browsers, like Chrome. HTTP requests contain an operation to tell the server what to do.
Common HTTP operations include:
- GET for retrieving server data
- POST or PUT for add/create/update the server with new data
- DELETE for deleting data from the server
Your app will make an HTTP GET request to the server for the Mars photos information, and then the server returns a response to our app including image urls.
The response from a web service is commonly formatted in one of the common web formats like XML or JSON – formats for representing structured data in key-value pairs. You learn more about JSON in the later task.
In this task, you establish a network connection to the server, communicate with the server, and receive a JSON response. And we will be using a backend server that is already written for you. In this Part we will use the Retrofit library, a third party library to communicate with the backend server as shown in Picture.
Catch Up PART 2
No comments:
Post a Comment