0
I need to submit a POST request to the following address which is an Amazon API:
https://ikd29r1hsl.execute-api.us-west-1.amazonaws.com/prod/contaazul/grade
And in this request a JSON has to be sent:
{
"token": "633cc5hs58512b012104c7408d60d19930d5514",
"email": "[email protected]",
"answer": [
{"date": "2017-09-01", "value": 100},
{"date": "2017-09-02", "value": 200},
{"date": "2017-09-03", "value": 150}
]
}
Could someone shed some light on how I do this with Java? There is a class that does this kind of operation?
Retrofit works perfectly in Java projects, and I find it very efficient - https://futurestud.io/tutorials/retrofit-send-objects-in-request-body
– Weslley Barbosa
It’s true, there’s Retrofit too, just remembering that it’s aimed at Web Services REST (probably the case with Amazon), while the forms cited are more generic.
– Piovezan
In vdd Retrofit is an implementation of Okhttp, which saves you a lot of time in creating requests, because you avoid too much code fatigue
– Weslley Barbosa
Retrofit is an API developed by Square following the REST standard... / Retrofit is a REST Client for Android and Java by Square... / Retrofit is a type-safe REST client for Android (or just Java) developed by Square... And what you said is contradictory. If Retrofit does the same thing as Okhttp, why does one wheel on top of the other? Because Square would create two libraries that do the same thing?
– Piovezan
Retrofit is an implementation of Okhttp as well as Serveface and a JSP implementation, so much so that the Retrofit startup vc has option to insert an Okhttp client
– Weslley Barbosa
The question that Retrofit helps you to treat entities directly in the request instead of dealing with the response bytes and do a control to convert
– Weslley Barbosa
...provided that your web API is REST. And do not say implementation; Retrofit is not a specification that Okhttp implements, nor vice versa. Okhttp is used as networking layer Retrofit, that is, Retrofit uses Okhttp. When you proposed Retrofit you implied that it was an HTTP request facilitator. But Okhttp is already that, and I said that they do not share the same utility because they have different goals. Okhttp simplifies HTTP requests. Retrofit works one level up, mapping REST calls (not any HTTP call) to objects.
– Piovezan