get参数细节修改
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
||||
|
||||
public object DoRequest(string url, JObject jObject, out string msg)
|
||||
{
|
||||
|
||||
msg = String.Empty;
|
||||
try
|
||||
{
|
||||
var method = "POST";
|
||||
@@ -32,7 +32,10 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
||||
method = jObject["Method"].Value<string>();
|
||||
}
|
||||
if ("GET".Equals(method, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
url = GetGetUrl(url, jObject);
|
||||
_LogHelper.Info($"93段接口url:{url}");
|
||||
}
|
||||
HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest;
|
||||
|
||||
var head = jObject["Head"];
|
||||
@@ -64,11 +67,13 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
||||
r = GetResponse(httpWebRequest, encoding);
|
||||
}
|
||||
|
||||
msg = String.Empty;
|
||||
_LogHelper.Info($"93段接口:method:{method},url:{url},参数:{jObject["Data"]},结果:{r}");
|
||||
return r;
|
||||
}
|
||||
catch (WebException e)
|
||||
{
|
||||
_LogHelper.Info("异常:" + Newtonsoft.Json.JsonConvert.SerializeObject(e));
|
||||
if (e?.Response != null)
|
||||
{
|
||||
using (var stream = e?.Response?.GetResponseStream())
|
||||
{
|
||||
@@ -88,6 +93,12 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += e.Message;
|
||||
_LogHelper.Info("2:请求错误原因为:" + msg);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg = e.Message;
|
||||
@@ -101,19 +112,29 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
||||
var jParam = jObject["Param"];
|
||||
if (jParam != null)
|
||||
{
|
||||
var Param = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jParam.ToString());
|
||||
var Param = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(jParam.ToString());
|
||||
foreach (var item in Param)
|
||||
{
|
||||
url += $"{item.Key}={item.Value}";
|
||||
url += $"&{item.Key}={item.Value}";
|
||||
}
|
||||
}
|
||||
|
||||
var jdata = jObject["Data"];
|
||||
if (jdata != null)
|
||||
{
|
||||
var Data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jdata.ToString());
|
||||
var Data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(jdata.ToString());
|
||||
foreach (var item in Data)
|
||||
{
|
||||
if (item.Value is JArray)
|
||||
{
|
||||
foreach (var arr in (JArray)item.Value)
|
||||
{
|
||||
url += $"&{item.Key}={arr}";
|
||||
}
|
||||
}
|
||||
else if (item.Value is JObject)
|
||||
url += $"&{item.Key}={Newtonsoft.Json.JsonConvert.SerializeObject(item.Value)}";
|
||||
else
|
||||
url += $"&{item.Key}={item.Value}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user