Join or unjoin a set of queues for a user using .NET SDK

Hi,

I am trying to join/unjoin set of queues for a user using .NET SDK. When creating the body request, it does let me assign the ID value.

I get the following compile time error: Property or indexer 'UserQueue.Id' cannot be assigned to -- it is read only

This is the code in the UserQueue class of the SDK:

//
// Summary:
//     The globally unique identifier for the object.
//
// Value:
//     The globally unique identifier for the object.
[DataMember(Name = "id", EmitDefaultValue = false)]
public string Id { get; private set; }

My JSON payload for the body is as below and it works fine from Postman.

[
    {
        "id": "id_of_queue1",
        "joined": false
    },
    {
        "id": "id_of_queue2",
        "joined": true
    }
]

This is the code that I am trying:

var body = new List<UserQueue>()
{
    new UserQueue() {
        Id = "", // Property or indexer 'UserQueue.Id' cannot be assigned to -- it is read only
        Joined = false
    }
};

var result = await _usersApi.PatchUserQueuesAsync(userId, body);

Since the ID property is private set, how do I pass the queue ID?

Please open a case with Genesys Cloud Care to report this issue. This is a bug with the API's definition that has incorrectly marked a request object property as read-only.

There are a few possible workarounds in the meantime:

  • Construct the JSON object as a string and use the JSON deserializer to parse it into the object (private setters work during deserialization)
  • Create your own class that inherits from that class that overrides the setter behavior or otherwise provides a means to set the private property. (I'm not 100% this will work; it's been a long time since I've used .NET and I don't remember inheritance rules off the top of my head)
  • Make the request manually so you're not bound by the SDK's definition. You can still use the ApiClient.CallApi.(..) function to make use of the SDK's general functionality, but using your own class for the request body type.

Hi Nandksishor,

Make sure you reference this post in your Care case and that Developer Engagement asked you to open a care ticket. Sometimes our care team will redirect people back to the forum so including the post in the forum will provide additional context.

Thanks,
John Carnell
Director, Developer Engagement

I have opened the case. Thank you