Creating Leaderboards with the AdminApiClient

,

I’m trying to setup a Leaderboard using the AdminApiClient via Cloud Code.

I’m getting this error back:

{"code":1002,"detail":"json: cannot unmarshal number 25.0 into Go struct field LeaderboardConfig.bucketSize of type storage.BucketSize","instance":null,"requestId":"1380beb7-cded-41cb-a9ed-efe03087fa85","status":400,"title":"Error","type":"problems/basic"}"

Any idea how to solve this?

What are you sending? It seems to indicate that the json you send is the problem. It could be malformed.

But more likely the Leaderboard bucketSize field expects a different type. Possibly an integer ie “25” instead of “25.0”.

I’m actually surprised Claude wouldn’t be able to figure it out. I just pasted your post verbatim in my running Opus @ medium and without checking any live project or documentation it responded:

[19:55 CEST] Captain on the bridge! Yes — that error is a type problem in the request you are sending, not a problem with the value.
The service is Go, and bucketSize is an integer type there. Go’s JSON decoder refuses the literal 25.0 for an integer field even though the value is a whole number: it rejects it on the form of the literal, not on whether it has a fractional part. So the fix is to make the serialized JSON say 25, not 25.0. The value is already correct.

So you had the solution all along. :wink:

This was using the C# AdminApiClient v0.0.21. The BucketSize in that version was defined as a decimal type. I’ve updated to v0.0.27 and its fixed - defined as an int type now