我正在尝试使用API上传文本文件,但它无法正常工作 目标url / api url是 http://221.132.117.58:7700/voice_api/voice_api_file_upload.html
方法是POST
必需参数:用户名,密码,CLI,campaignName *,promptID,fileUpload(每个广告系列的campaignName必须是唯一的。)
可选参数:scheduleDatetime示例2016-11-15 16:45:00 ....
我的代码
namespace doc
{
class Program
{
public static void Main(string[] args)
{
Console.Write("Please enter the URI to post data to : ");
string urlString =string.Format("http://enterprise.mobilinkcms.com/voice_api/voice_api_file_upload.php");
var URI = new Uri(urlString);
var uri = new Uri(URI);
var path = Path.GetFileName(uri.AbsolutePath);
var file = GetFile(path);
WebClient myWebClient = new WebClient();
//Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI");
string fileName = "http://enterprise.mobilinkcms.com/voice_api/aa.txt";
Console.WriteLine("Uploading {0} to {1} ...", fileName, uriString);
DateTime begin = DateTime.Now;
byte[] responseArray = null;
try
{
responseArray = myWebClient.UploadFile(file, fileName);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString());
}
DateTime end = DateTime.Now;
}
}
}
显示的错误是
请求类型'System.Security.Permissions.FileIOPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败。