"context does not contain a valid ResourceContext" error on API Call

I am trying to add player score with this command: https://services.docs.unity.com/leaderboards/index.html#tag/Leaderboards/operation/addLeaderboardPlayerScore it gives this error:

{"type":"problems/basic","title":"Error","status":400,"detail":"context does not contain a valid ResourceContext","instance":null,"code":1003}

I can’t find any explanataion about that error.

My request data:

POST /v1/projects/<My Project ID>/leaderboards/Lb1/scores/players/siTkJehWoyJCMEXXQh6Uui6MMXb9 HTTP/1.1
Accept: */*
Accept-Encoding: deflate, gzip
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Host: leaderboards.services.api.unity.com
Authorization: Bearer <My Stateless Token>
Content-Type: application/json
Content-Length: 12

{"score":10}

Hey muhammet,

From our logs, it looks like your requests are missing the environmentId, which is why you’re getting the “context does not contain a valid ResourceContext” error. I agree this error message isn’t helpful, and we’ll look into improving it.

You can fix this by including your environmentId when doing the token exchange.

For example:

POST https://services.api.unity.com/auth/v1/token-exchange?projectId={{projectId}}&environmentId={{environmentId}}

You can check out docs for service account authentication here.

If you have any other issues, don’t hesitate to reach out.

Jamie

1 Like

Thank you for your fast reply, it solved my problem. Have a good day.

1 Like