How to create JSON client call passing in Multipart form data

I’m trying to pass in multiple Form variables to a remote server, and the only practical way I can see is to use PostFilesWithRequest with a class containing all the properties I need in the text values (is there a better way?)
It works as long as the remote server returns a specific known type, but if the remote server returns an error message (such as {"error":"There were errors with your request."}) we get an “Index was outside the bounds of the array” no matter what we do with the return data type.

The call looks like this:

response = client.PostFilesWithRequest<object>(baseurl, new FormsVarsRequest(), new List<UploadFile>());

How do I access the actual returned string or object, and is this the only way to send form data in multipart format?
Now this may be a non-conformant JSON service, as it’s returning a different structure for error conditions, but I’d still like to know if this is the best way of passing Form data or if there’s a preferred approach.

Do you use ServiceStack-based remote server or this is some third party server? If it’s third party server can you provide all data about this response (headers, body and so on). You can get these data with fiddler. If you use service based on ServiceStack can you provide and example how do you return error message which will break PostFilesWithRequest?

JsonServiceClient uses PostFile and PostFileWithRequests methods to post multipart/form-data to the services, there are also two methods PostFileAsync and PostFileWithRequestAsync in JsonHttpClient class of ServiceStack.HttpClient package which do similar job.

Please note we do not support using ServiceStack Service Clients to call non ServiceStack Services. You can use HTTP Utils or another general purpose HTTP Client.

Also never use object when deserializing Types, there is no way for the clients to know what the object is. You need to either specify the Typed Response DTO otherwise you need to access the raw Response.