You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
998 B
C#
36 lines
998 B
C#
using System;
|
|
using RestSharp;
|
|
|
|
namespace Tool
|
|
{
|
|
public class HttpUtil
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 提交json字符
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="obj"></param>
|
|
/// <returns></returns>
|
|
public static string PostJson(string url, object obj)
|
|
{
|
|
try
|
|
{
|
|
var client = new RestClient(url);
|
|
var request = new RestRequest();
|
|
request.AddHeader("Content-Type", "application/json");
|
|
request.Method = Method.Post;
|
|
request.Timeout = TimeSpan.FromMinutes(2);
|
|
request.AddBody(obj, ContentType.Json);
|
|
var response = client.Execute(request);
|
|
return response.Content;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ILogNetFactory.GetLogNet.WriteError(e.Message);
|
|
return e.Message;
|
|
}
|
|
}
|
|
}
|
|
} |