I want to get places by category by this request:
https://graph.facebook.com/v2.11/search?type=place¢er={lat,lng}&categories=["FOOD_BEVERAGE"]
I'm sending categories as query with retrofit as List<String>
But it returns:
{
"error": {
"message":"(#100) For field 'placesearch': param categories must be an array.",
"type":"OAuthException",
"code":100,
}
}
I was trying to do this by ArrayList
, making this query as String
literaly but it still return me that it need an array. How can I pass this ?
Retrofit interface
@GET("search")
fun getPlaces(
@Query("center") center: String?,
@Query("access_token") token: String?,
@Query("type") type: String?,
@Query("categories") categories: List<String>
): Observable<Places>
You can add a custom converter factory that converts a List<String>
into a String
of the correct format. Check out this example , instead of an Enum
you have a List<String>
and at the GetSerializedNameValue()
method you would instead use:
value = categories_list.joinToString(
separator = ", ",
prefix = "[",
postfix = "]"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.