日期:2014-05-18 浏览次数:21063 次
public static string ModifiyFixedCost(CookieContainer cookieContainer)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://10.63.11.34/vCenter-CB/api/hierarchy/696/entity/697/costModel/701/fixedCosts/values");
request.CookieContainer = cookieContainer;
request.Method = "PUT";
request.KeepAlive = true;
request.Timeout = 600000;
request.ContentType = "application/x-www-form-urlencoded";//application/x-www-form-urlencoded
Stream streamReq = request.GetRequestStream();
///Read XML file.
String strXML;
string strCurrentPath = System.IO.Directory.GetCurrentDirectory();
string strPath;
strPath = strCurrentPath + "\\ModifiyFixedCostXML.txt";
using (StreamReader sr = new StreamReader(strPath))
{
strXML = sr.ReadToEnd();
}
string strResp;
byte[] byteArray = Encoding.UTF8.GetBytes(strXML);
streamReq.Write(byteArray, 0, byteArray.Length);
streamReq.Close();
using (WebResponse response = request.GetResponse())
//报异常:WebException was unhandled: The remote server returned an error:(500)Internal Server Error.
//Trace: at System.Net.HttpWebRequest.GetResponse()
at ChargeBack.ChargeBack.ModifiyFixedCost(CookieContainer cookieContainer) in C:\Users\Administrator\documents\visual studio 2010\Projects\ChargeBack\ChargeBack\ChargeBack.cs:line 340
at ChargeBack.ChargeBack.Main(String[] args) in C:\Users\Administrator\documents\visual studio 2010\Projects\ChargeBack\ChargeBack\ChargeBack.cs:line 86
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
{
Stream streamResp = response.GetResponseStream();
StreamReader streamReaderResp = new StreamReader(streamResp);
strResp = streamReaderResp.ReadToEnd();
}
return strResp;
}