Sto creando un RestSharp.RestRequest tramite:La sovrascrittura di RestSharp imposta manualmente Content-Type?
RestRequest request = new RestRequest();
request.Method = Method.POST;
request.Resource = "/rest-uri";
request.AddHeader("Content-Type", "application/someContentType");
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + Environment.NewLine +
"<register-request">" + Environment.NewLine +
" <name=\"someName\"/>" + Environment.NewLine +
"</register-request>");
request.AddParameter("text/xml", registerSinkRequest, ParameterType.RequestBody);
(Il Content-Type è impostato manualmente application/someContentType
)
In modalità debug mostra anche Content-Type=application/someContentType
Ma l'esecuzione della RestRequest restituisce un 415 Media Not Supported
-Errore e WireShark indica che il Tipo di supporto è impostato su text/xml
(come impostato nel metodo AddParameter).
Perché RestSharp mostra un diverso tipo di contenuto, quindi WireShark? E come posso impedire che il tipo di contenuto venga modificato (se lo è)?
Quindi perché non si utilizza l'applicazione/someContentType in? AddParameter() '? – svick