Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Server error while performing a GET to the v1/me/player/recently-played endpoint

Server error while performing a GET to the v1/me/player/recently-played endpoint

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
2 Replies

I'm having same problem with Python, did you get to manage this by yourself? thanks

I am also getting this error. Is there any solution for this?

gofelishago_0-1704010551823.png

 

Suggested posts