admin管理员组文章数量:1024593
hello im using android app trying to parse the content from this api
BaseURL "/v1/"
URL
/stories
Parameters
page as int, optional
size as int, optional
location as 1 | 0, optional, default 0
Notes:
1 for get all stories with location
0 for all stories without considering location
Method
GET
Headers
Authorization: Bearer <token>
Response
{
"error": false,
"message": "Stories fetched successfully",
"listStory": [
{
"id": "story-FvU4u0Vp2S3PMsFg",
"name": "Dimas",
"description": "Lorem Ipsum",
"photoUrl": "/images/stories/photos-1641623658595_dummy-pic.png",
"createdAt": "2022-01-08T06:34:18.598Z",
"lat": -10.212,
"lon": -16.002
}
]
}
i already followed the api doc but i keep getting 400 bad req
this is my logcat
my api service
interface ApiService {
@GET("stories")
suspend fun getStories(
@Header("Authorization") authorization: String,
@Query("page") page: Int,
@Query("size") size: Int,
): StoryResponse
}
my story repository
class StoryRepository(
private val apiService: ApiService,
private val sessionManager: SessionManager
) {
suspend fun getStories(token: String): List<ListStoryItem> {
val token = sessionManager.getToken()
val page = 1
val size = 10
return apiService.getStories("Bearer $token", page, size).listStory
}
}
i already test with thunder client and it return 200 this token is from prev test
hello im using android app trying to parse the content from this api
BaseURL "/v1/"
URL
/stories
Parameters
page as int, optional
size as int, optional
location as 1 | 0, optional, default 0
Notes:
1 for get all stories with location
0 for all stories without considering location
Method
GET
Headers
Authorization: Bearer <token>
Response
{
"error": false,
"message": "Stories fetched successfully",
"listStory": [
{
"id": "story-FvU4u0Vp2S3PMsFg",
"name": "Dimas",
"description": "Lorem Ipsum",
"photoUrl": "/images/stories/photos-1641623658595_dummy-pic.png",
"createdAt": "2022-01-08T06:34:18.598Z",
"lat": -10.212,
"lon": -16.002
}
]
}
i already followed the api doc but i keep getting 400 bad req
this is my logcat
my api service
interface ApiService {
@GET("stories")
suspend fun getStories(
@Header("Authorization") authorization: String,
@Query("page") page: Int,
@Query("size") size: Int,
): StoryResponse
}
my story repository
class StoryRepository(
private val apiService: ApiService,
private val sessionManager: SessionManager
) {
suspend fun getStories(token: String): List<ListStoryItem> {
val token = sessionManager.getToken()
val page = 1
val size = 10
return apiService.getStories("Bearer $token", page, size).listStory
}
}
i already test with thunder client and it return 200 this token is from prev test
本文标签: kotlinwhy do i keep getting 400 bad request although my request is correct androidStack Overflow
版权声明:本文标题:kotlin - why do i keep getting 400 bad request although my request is correct android - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745609259a2158906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论