android


Sending a query Url USing Retrofit with params


I am working with retrofit libs I want to send a query Url like this
http://my.api.com/register/...
Can anyone please tell me how to do it?
I tried a lot of things, but I keep getting an exception
For example:
Call<Response> apiResponseCall = apiInterface.getUser(username,password,key);
System.out.print(apiResponseCall.toString());
System.out.print(apiInterface);
apiResponseCall.enqueue(new Callback<Response>() {
#Headers("Content-Type: application/json")
#POST("generate_auth_cookie/?")
Call<Response> getUser(
#Query("username=") String username,
#Query("&password=") String password,
#Query("&key=") String key );
OkHttpClient.Builder httpClient =
new OkHttpClient.Builder();
httpClient.addInterceptor(new Interceptor() {
#Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
HttpUrl originalHttpUrl = original.url();
HttpUrl url = originalHttpUrl.newBuilder()
.addQueryParameter("apikey", "your-actual-api-key")
.build();
// Request customization: add request headers
Request.Builder requestBuilder = original.newBuilder()
.url(url);
Request request = requestBuilder.build();
return chain.proceed(request);
}
});
ApiInterface service = ApiInterface.retrofit.create(ApiInterface.class);
Call<JsonResponse> myDownsized = service.getDownsized("dc6zaTOxFJmzC", "json", "funny", "1");
myDownsized.enqueue(new Callback<JsonResponse>() {
#Override
public void onResponse(Call<JsonResponse> call, Response<JsonResponse> response) {
if (response.isSuccessful()) {
for (Data data : response.body().getDataList()) {
System.out.println(data.getImages().getDownsized().getUrl());
//TextView text2 = (TextView) findViewById(R.id.first_text);
//Downsized dw = response.body();
//text2.setText(dw.getHeight());
}
} else {
//unsuccessful response
}
}
#Override
public void onFailure(Call<JsonResponse> call, Throwable t) {
//failed response
}
});

Related Links

can we register setOnClickPendingIntent in onEnable() method of AppWidgetProvider class in android?
LocationServices.FusedLocationApi.requestLocationUpdates onLocationChanged not being called back
Android Studio subprojects
how to bind menu xml file to list view in android
OnClick open URL (Json, ListView) Android
How to change Unity Android project name?
How to change the view of Spinner?
How can I make a ListView in Android Studio?
How to release the cached memory by pss in android
Custom list layouts not working in emulator
Android setter of String array
Error SearchView in ActionBar
Android hidden camera [duplicate]
CardView is not filled up completely by the RelativeLayout
Android mp4parser - create Track from Bitmap
Selendroid won't start some apps

Categories

HOME
fabricjs
microsoftgraph
gdb
linkedin
dns
github-for-windows
flex
interface
requirements
pclxl
permissions
nstableheaderview
bing-maps
emoji
opengl-es-3.0
supervisor
3nf
scrolltop
mvc-mini-profiler
video-editing
cfml
gmm
enterprise-miner
sar
drive
visual-glitch
blade
jquery-ias
named-entity-recognition
systemtime
stackexchange
oculus
handler
errbot
winpe
event-flow
livelink
weather
record
cart
hard-drive
keras-layer
sendbird
reactjs.net
least-squares
sharepoint-workflow
sql-server-ce
jpad
google-data-api
congestion-control
optimizely
pom.xml
term
activeperl
android-testing
trigger.io
offline.js
universal-analytics
slackware
neon
bizagi
gcloud-ruby
piracy-prevention
phonertc
batik
uvc
android-broadcast
xmltype
iiop
jqmodal
named-parameters
template-deduction
rcaller
jjaql
tinyxml
dot42
spring-remoting
file-not-found
amslidemenu
high-resolution
rfc5322
isqlquery
ebay-lms
process-explorer
merb
windows-98
sqlclr
idn
appjs
wiimote
ikimagebrowserview
umra
http-daemon
mtu
zend-rest
pagemethods
duplex
filesystemobject
product-management
pnrp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App