public RestClient(string endpoint, HttpVerb method, string postData, RestContentType contentType = RestContentType.XML) { EndPoint = endpoint; Method = method; ContentType = contentType == RestContentType.XML ? "text/xml" : "application/json"; PostData = postData; }
public RestClient(string endpoint, RestContentType contentType = RestContentType.XML) { EndPoint = endpoint; Method = HttpVerb.GET; ContentType = contentType == RestContentType.XML ? "text/xml" : "application/json"; PostData = ""; }
/// <summary> /// Creates a PUT rest request. /// </summary> public static RestRequest Put(RestUri uri, RestHeaders headers, RestContentType contentType, object content) => new RestRequest { Method = HttpMethod.Put, Uri = uri, Headers = headers, ContentType = contentType, Content = content, ContentEncoding = Encoding.UTF8 };
/// <summary> /// Rest接口输出的描述 /// </summary> /// <param name="desc">返回结果的描述</param> /// <param name="format">返回结构集的结构描述,比如:如果为JSON,则填写json的数据格式,如: /// { /// "code":"执行结果状态,success为成功,failed为失败", /// "msg":"执行结果的提示信息", /// "data":[结果集数组] /// } /// </param> /// <param name="type"></param> public EWRAOutputDescAttribute(string desc, string format, RestContentType type = RestContentType.JSON) { Desc = desc; FormatDesc = format; ReturnType = ComFunc.Enum2String <RestContentType>(type); }
/// <summary> /// 设定返回的content类型 /// </summary> /// <param name="contenttype"></param> public void SetContentType(RestContentType contenttype) { CallContext_DataCollection.ContentType = contenttype; }
/// <summary> /// Creates a PUT rest request. /// </summary> public static RestRequest Put(RestUri uri, RestContentType contentType, object content) => Put(uri, null, contentType, content);