【发布时间】:2014-03-23 06:01:21
【问题描述】:
我正在使用 WWW 与 RESTful Web 服务进行交互。不过,我在通过 POST 请求将 XML 文件发送到服务器时遇到问题。这是我的代码:
if(Syste.IO.File.Exists(filePath)){
byte [] raw = File.ReadAllBytes(filePath);
WWWForm form = new WWWForm();
form.AddBinaryData("fileUpload", raw, "", "text/xml");
WWW www = new WWW(host + auth + "/behaviors", form);
StartCoroutine(myCoroutine(www));
}
IEnumerator myCoroutine(WWW www){
yield return www;
if (www.error == null)
{
Debug.Log("Text: " + www.text);
proceedToNextRequest = true;
} else {
Debug.Log("Error: "+ www.error);
Application.Quit();
}
}
不过,来自服务器的回答是“不支持的媒体类型”,我不知道出了什么问题。我通常在 Google Chrome 上使用 POSTMAN 来发送这些请求,它工作正常。有什么建议吗?
【问题讨论】:
标签: c# xml rest unity-container