Search Unity

Resolved Can not update host player data with Bulk Update API

Discussion in 'Lobby' started by BSimonSweet, Dec 14, 2023.

  1. BSimonSweet

    BSimonSweet

    Joined:
    Aug 17, 2022
    Posts:
    67
    Hi !

    I think there is a bug with the Bulk Update API (https://services.docs.unity.com/lobby/v1/#tag/Lobby/operation/bulkUpdateLobby), when trying to update the player's data of the Host of the Lobby.

    The API returns a
    404
    error with the code
    16002
    and a message saying that the specified player
    is not found and cannot be updated
    , which should not happens since the player is the host. Note that I'm using a Service Account, as instructed in the documentation.

    The Bulk Update works with others players in the Lobby and I can update the player's data host data with the Update Player Data API (https://services.docs.unity.com/lobby/v1/#tag/Lobby/operation/updatePlayer).
     
  2. mcanfield_unity

    mcanfield_unity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    13
    Hi there! We use this api in one of our other services and haven't come across the issue. A team member also just tried to reproduce what you've described, but can't seem to get the `404`. Can you redact any proprietary aspects of your code and share a snippet that would get me into the same code flow scenario in which you're experiencing the error?
     
  3. BSimonSweet

    BSimonSweet

    Joined:
    Aug 17, 2022
    Posts:
    67
    Hi !

    Thanks for your answer. I dig a bit more and in the end the bug was on my side ...

    It was a bit sneaky, but long story short : I implemented my own C# binding for the UGS API (works great), but so far didn't use the BulkUpdate API. To serialize players data I use a dictionary, with the key as the player's ID, and also use
    System.Text.Json
    for JSON.

    I used a
    JsonSerializerOptions
    that was transforming the case of dictionaries keys to camel case (
    DictionaryKeyPolicy
    set to
    JsonNamingPolicy.CamelCase
    ), and in a strange odd, only the ID of the main player account I use is formatted in a way that would change it once in camel case and all others players accounts I was using don't have an ID that change once in camel case.

    I fixed it by not changing the case of dictionaries keys ...