0

I'm calling a microservice API using RestSharp with a POST message in a RestClient ExecuteAsync call for testing purposes. The data is coming back null and an error message is being returned as Data at the root level is invalid. Line 1, position 1.

The call works otherwise in the normal course of using the API in our application. The API returns a FileContentResult. I see information in the Content.

        public static async Task<IRestResponse<FileContentResult>> ExecuteAsyncFileRequests(this RestClient client, IRestRequest request)
        {
            var response = await client.ExecuteAsync<FileContentResult>(request);
            return response;
        }
BermudaLamb
  • 273
  • 3
  • 5
  • 24

1 Answers1

1

Your server probably returns some error as HTML, and deserialization of the response fails for that reason. It's easy to check by calling

var response = await client.ExecuteAsync(request);

and inspecting the response.Content property.

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83