I'm using RestSharp to interface with the Auth0 API. Everything's working fine except when deleting a user. I send the delete request as a DELETE and Auth0 successfully deletes the user.
Here is the response I'm getting from Auth0:
HTTP/1.1 204 No Content
Date: Mon, 17 Feb 2020 22:40:51 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Server: nginx
And here's what I'm getting in the RestSharp response:
System.Runtime.Serialization.SerializationException: Invalid JSON string
at RestSharp.RestClientExtensions.ThrowIfError(IRestResponse response)
at RestSharp.RestClientExtensions.DeleteAsync[T](IRestClient client, IRestRequest request)
Here's a code snippet:
public virtual async Task<IRestResponse> DeleteAsync(string userId)
{
var request = new RestRequest($"{_config.ManagementApiBaseUrl}/api/v2/users/{userId}");
request.Method = Method.DELETE;
var response = await Client.DeleteAsync<RestResponse>(request);
return response;
}
As mentioned above, the request is sent and processed on the Auth0 side, but then RestSharp tries to deserialize the (non-existent) response body.
What am I doing wrong?