Server error while performing a GET to the v1/me/player/recently-played endpoint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to perform a request to the 'v1/me/player/recently-played' endpoint in a Kotlin Ktor client application (code snippets below, but the same happens in Postman). The interesting fact is that if i use the Bearer token gotten from the API docs, from the try it section, it works.
I'm successfully getting the accessToken by doing this:
val clientCredentials =
"clientId:clientSecret".toByteArray().encodeBase64()
val token = client.post<String>("https://accounts.spotify.com/api/token") {
header(HttpHeaders.ContentType, ContentType.Application.FormUrlEncoded.toString())
header(HttpHeaders.Authorization, "Basic $clientCredentials")
body = "grant_type=client_credentials&scope=user-read-recently-played"
}
And then, the actual call to the aforementioned endpoint:
val decodedToken = Json.decodeFromString<Token>(token)
val response = client.get<String>("https://api.spotify.com/v1/me/player/recently-played") {
accept(ContentType.Application.Json)
header(HttpHeaders.Authorization, "Bearer ${decodedToken.accessToken}")
}
I end up getting:
{
"error": {
"status": 500,
"message": "Server error."
}
}
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page