What is the best practise for REST API call? [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Currently I am working on an Android app what needs to call a Spring Boot REST API for some data stored in DB. What is the best practise to handle REST API calls from Android? I am interesed in the most clear way.
Do I need HTTPS or HTTP is enough? I will storing some user based data, but not like personal.or something. The most personal data would be email address. I am using Java.

I suggest you to use Retrofit 2 which is a powerful REST API client!
Also I found Futurestudios tutorials quite useful to learn how to use it in an android app.
As others already suggested I'd always use https:// nowadays.

Try the MVVM pattern with Repository pattern.
Here are the Architecture samples from Google
https://github.com/googlesamples/android-architecture
Apart from this use Retrofit to make remote API calls. In sample they are mocking the data so replace it with your api call.
Link to retrofit: https://square.github.io/retrofit/
How to consume REST services using Retrofit: https://android.jlelse.eu/consuming-rest-api-using-retrofit-library-in-android-ed47aef01ecb

Related

Custom Rest Api Java Authentication using Firestore [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I was wondering how to create a java rest api where there is possibility to create something like a "signUp" and "signIn" user authentication to firestore (given it tokens). Supporting it with endpoints which can be accessed with for example postman or swift or android app when the api link is provided.
If I understood your question correctly, you would like to build a REST API which internally authenticates against Firestore? This can definitely be done by exposing the Firebase REST API for authentication with the Java binding for admin accesses.

How to pass data from server to android app: REST vs Sockets [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'am writing an android app that needs some data from the server. I am also writing the server side in Java.
What is the best way to pass data from the server to the android device: with REST or Sockets (like Kryonet)?
In what format: XML/JSON (for REST) or plain Java objects?
Thanks in advance.
"Best" is very subjective, I think a very good way to communicate with a RESTful api is via Square's Retrofit library, which can be found here:
http://square.github.io/retrofit/
There is also Volley from Google,
http://developer.android.com/training/volley/index.html
Agree with nPn, "Best" depends on lot of app and user considerations. That said,
REST is preferred as it is most widely used and you have access to stable and optimized client libraries. Most of the these libraries support all kinds of use-cases and customizations. Web Sockets are well suited for real time or live content. If you have a different use-case , REST is strongly recommended.
With Android, JSON is well supported. There is a core JSON API included with Android that you can use without any client libraries. XML can be helpful if you plan to expose your APIs for public consumption (some platforms eg: JAVA, windows have strong XML legacy).
REST + JSON seems to be most commonly used combination in recent times, and lot of client libraries usually enable this use-case.

Java Web Services - Intacct Application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to Java environment. I have to create a java utility to extract information from an external application using web-services.For that I need to send an XML request and receive the response. I am browsing around the web and couldn't find any better article. I want to know how to send a XML request and print the request and the response using Java. Any good reference should also help.
Given that you are using Java, you should check out the Java specifications for
JAX-RS: Spec for Java REST services
JAX-WS: Spec for Java XML Web services (this roughly is the SOAP spec)
Both of these topics are extensive. FWIW REST seems to be the style-of-choice today. SOAP was prevalent several years back, but for several reasons (simplicity, ease of implementation), REST has surpassed SOAP. Of course if you have a target web service in mind, the style of the service makes the REST/SOAP choice for you.

How to make an API call from a RESTful service in Java? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to the restful web services. So my knowledge is minimal about the topic. I am developing a restful service in Java & I want to call an Amazon web service API from inside the service. Is this possible? How many ways can I do this?
There's no difference to any other java program. Just call the URL using a HTTP Client. A popular one ist the HttpClient from Apache HttpComponent.
Take a look at Jersey framework. If I understand you correctly, you should find this section of the documentation useful.

How use Java with google maps api? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Java with Google maps api
I'd like to begin a project with Java that needs a map. I've been thinking about either Google Maps or another Open Source map. How would I implement this?
First of all, I would offer you to use google maps api, they are using REST services and they are very good.
Here is a short explantation:
You need to make an HTTP request with a URL with the parameters you wish (such as the location - longtitude, latitude, the address, and more), this code should be made in java. If you did everything correct, you will recieve a response of type (xaml or json, depends on the URL you sent, it is preferable to use JSON).
After you receive the response you need to deserialize it, which seems to be hard, but is very simple, for example JSON has many ways and built in methods to do it.
And then you can do whatever you wish with the objects you received.
So here are some links:
Google API - https://developers.google.com/maps/documentation/geocoding/?hl=en and https://developers.google.com/maps/documentation/staticmaps/?hl=iw&csw=1
JSON Deserialize - http://james.newtonking.com/json/help/index.html?topic=html/LINQtoJSON.htm or a better one (if you want to make many requests) - http://blogs.msdn.com/b/webdev/archive/2012/12/18/paste-json-as-classes-in-asp-net-and-web-tools-2012-2-rc.aspx
How about this?
The Google Geocoding API
The Google Directions API
The Google Distance Matrix API

Categories