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

Android preference, how to set dependancy on custom preference
Android Video Screen Orientation
Cursor for an Image always returns null
sendJavascript function not defined error in Cordova Plugin salesforce
prevent android from killing fragment
Android - Create google map projections V2
recycling views in scroll view
Email link not working on mobile site wrapped by an Android app.
Using AT commands with an Android phone
Adding GCM push service notification to an existing Android application
how to remove spaces between bars?
Displaying Android Action Bar
Updating and sharing a variable between 3 classes
ActivityNotFoundException Android App
Date comparison Sqlite Android
runOnUiThread in fragment

Categories

HOME
search
microsoftgraph
adal
api
nvd3.js
fpga
android-studio-2.2
nunit
mjml
camera
sublimetext
webix
opengl-3
teechart
java.util.logging
frequency-distribution
scsi
symfony-2.8
atlassian-stash
cfml
boost-icl
selinux
simpleitk
poedit
squashfs
gulp-watch
displaytag
data.stackexchange.com
jasmine-node
handler
python-2.6
pdw-file-browser
google-knowledge-graph
projects-and-solutions
demo
doc
laravel-elixir
apriori
wmp
logback-groovy
angular-http
wc
signal-strength
sonarlint-eclipse
cnc
trojan
page-replacement
java-bytecode-asm
context-sensitive-grammar
colorbar
git-flow
arules
dt
check-mk
java-websocket
universal-analytics
shinobi
atlas
watch-os-2
qiime
nservicebus5
grass
cycle2
highland.js
lazybones
slash
ember-cli-rails
jdk1.7
typemock
xmltype
android-vibration
big-ip
appserver
genymotion-call
imagefilter
universal-image-loader
strawberry-perl
jama
ora-00904
malformedurlexception
memset
ora-06550
notorm
breakout
windows-phone-8-sdk
model-driven-development
dolby-audio-api
stacky
cardreader
redis-py
vfs
os.system
dajaxice
cuteeditor
globals
non-clustered-index
object-database
jqueryform
drupal-fivestar
tabpanel
wspbuilder
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App