I tried to get the facebook wall data.I got my access token by using
accesstoken=Login.mFacebook.getAccessToken();
Log.e("accesstoken",accesstoken);
But while calling
String wallres=UrltoValue.getValuefromUrl("https://graph.facebook.com/me/feed? access_token=accesstoken");
Log.e("wall res",wallres);
I am getting Bad Request as response
By calling this code you say that accesstoken is literally part of the URL.
String wallres=UrltoValue.getValuefromUrl("https://graph.facebook.com/me/feed? access_token=accesstoken");
I think you meant to do this, so that you use the previously defined variable accesstoken:
String wallres=UrltoValue.getValuefromUrl("https://graph.facebook.com/me/feed? access_token=" + accesstoken);
I have already a problem like this. Try remove the spaces or convert it to %20.
String wallres=UrltoValue.getValuefromUrl("https://graph.facebook.com/me/feed?access_token=accesstoken");
Log.e("wall res",wallres);
Regards, Hugo Pedrosa
Related
I have really strange problem. Use retrofit to send request.
#POST("api/v2/reviews/vote/{vote}/dislike/{dislike}")
Single<SimpleResponse> postReviewLike(#Path("vote") Integer vote, #Path("dislike") Integer dislike);
This is my request. But when I send it to server - retrofit converted it to GET request. Bellow photo for a proof.
Can you suggest, what it can be? And how I can fix it.
With other POST request all is good, if I use #Field.
Could you please try this out using the #Body annotation?
#POST("api/v2/reviews/vote/{vote}/dislike/{dislike}")
Single<SimpleResponse> postReviewLike(#Body #Path("vote") Integer vote, #Path("dislike") Integer dislike);
Problem was with redirect. Adding '/' dislike/{dislike}/ helped me.
I am trying to send an array as parameter in GET request in Retrofit
Eg: prod = [1,2,3,4]
Tried almost every solution present on Stack OverFlow, GitHub
Non of them worked
Can someone explain how to make an array and send get request in RetroFit
Thankyou in advance!
You can try like this
#GET(".....")
Call<ResponseBody> getSomthingApi(#Query("prod") ArrayList<String> values);
I want to consume athe api located at http://base-url/delivery-orders?driverId.equals=1116
This is my function:
#GET("delivery-orders")
fun getAllDeliveryOrder(
#Header("Authorization") token: String,
#Query("driverId") idDriver: Int
): Observable<OrderItems>
but I got error code 500.
Error codes from 500-599 are server errors. Meaning, your code is working but the server doesn't. Better recheck the code from the server to fix this error.
This problem usually from server..
try to check Method or maybe there has invinity looping.
My friend also get the same problem, he say you must check database. Maybe your web can't call some data in database. just try delete all or make empty database, and then run again ur Android
I found the problem about that request. the problem is the URL have driverId.equal and my network interface is
#GET("delivery-orders")
fun getAllDeliveryOrder(#Header("Authorization") token: String, #Query("driverId") idDriver: Int): Observable<OrderItems>
so retrofit think driverId on URL is driverId in #Query, so I just change "driverId" in #Query with IdDriver. that solve the problem.
#Get("/ServiceTest?version=1&dateRange={dateRange}")
ResponseModel getDateRangeTest(String dateRange);
in RestClient interface this make the following Get
http://localhost:8080/ServiceTest/2014-01-29%25202014-01-29?version=1" resulted in 400 (Bad Request); invoking error handler
Am i doing something wrong in sending the query params.
I want address this way:
/ServiceTest?version=1&dataRange=2014-01-29%25202014-01-29
Which in this case somehow i am failed to generate with Android annotations #Get
Answer: My calls were not correct and main problem was with uri encode, correct one is
/ServiceTest?version=1&dataRange=2014-01-29%202014-01-29
you might do wrong.
Your server get /ServiceTest
but you access server with address /ServiceTest/2014-01-29%25202014-01-29
Look careful that your server receive as /ServiceTest?version=1&dateRange={dateRange}
and {dataRange} is what you intend to give as variable.
Your address should be /ServiceTest?version=1&dataRange=2014-01-29%25202014-01-29
== EDIT ==
I'm not familiar with Android Get annotation, but try this.
#Get("/ServiceTest?version=1&dateStart={dateStart}&dateEnd={dateEnd}")
ResponseModel getDateRangeTest(String dateStart, String dateEnd);
and access with /ServiceTest?version=1&dataStart=2014-01-29&dateEnd=2014-01-29
Note that I change argument for more specific. and it would be a better approach.
From my experimenting so far, it appears that Volley accesses its cache based on the URL alone. I would like to know if it also can determine which response it should return based on the combination of URL and request body data.
Is there a setting for this, or and extension point where I can implement this myself.
I don't see anywhere that the request body data is returned in the NetworkResponse object, or I would do the check in the parseNetworkResponse method.
Thanks
You have to override Request.getCacheKey() method to include request body as well, when implementing your custom request.