response.ErrorException = {"Invalid JSON string"} when removing user from organization (URGENT)

When I removed an user from organization, restsharp throws me this error : response.ErrorException = {“Invalid JSON string”}, even when the user has been removed successfully

I think the problem is with the deserialization but I’m not sure. Can someone help me? this is kind of urgent

this is the method to remove the user:

string[] accountIds = users.Select(user => user.AccountId).ToArray();

RestRequest request = new RestRequest($"/rest/servicedeskapi/organization/{organizationId}/user", Method.DELETE);

request.AddJsonBody(new { accountIds = accountIds});

This is the method to execute the process:

public IRestResponse<T> Execute<T>(IRestRequest request)
            where T : new()
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Basic " + this.encodedApiToken);
            IRestResponse<T> response = this.client.Execute<T>(request);

            // Check for exceptions
            if (response.ErrorException != null)
                throw new ApplicationException("Error retrieving response.", response.ErrorException);

            return response;

Errors from response:

|response|"StatusCode: NoContent, Content-Type: application/json; charset=UTF-8, Content-Length: -1)"|RestSharp.IRestResponse&lt;FVREB.JiraServiceDeskApi.Models.UsersOrganizationUpdateDTO&gt; {RestSharp.RestResponse&lt;FVREB.JiraServiceDeskApi.Models.UsersOrganizationUpdateDTO&gt;}|

|ErrorException|{"Invalid JSON string"}|System.Exception {System.Runtime.Serialization.SerializationException}|

||ErrorMessage|"Invalid JSON string"|string|



Welcome to Atlassian Developer Community forums, @Developer1!

Based the response below and the successful end result of having your user removed, I believe you got the expected response status of 204 No Content.

Remove users from organization REST API returns a 204 No Content with an empty response body for successful requests; I am not yet familiar with RestSharp and how it evaluates an empty response body, but maybe this is a good place to start checking?

Hope this helps.