글
- 오픈소스 http 클라이언트 라이브러리
- 공식 사이트 http://restsharp.org/
- GitHub https://github.com/restsharp/RestSharp
- 소개 http://pawel.sawicz.eu/restsharp/
- 예제 http://stackoverflow.com/questions/10226089/restsharp-simple-complete-example
1) 시작 번호 + 크기까지의 숫자범위를 문자로 얻는다.
var client = new RestSharp.RestClient(ServerConfig.LogServerURI); //http://localhost:10301/GameService
string RestAPI = string.Format("{0}/{1}", "RequestRangeNumber, 10);
var request = new RestSharp.RestRequest(RestAPI, RestSharp.Method.GET);
var queryResult = client.Execute<List<string>>(request).Data;
// 답변 포맷은 "10_20 "
var TokenString = queryResult[0].Split(new Char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
2) 요청 데이터를 클래스 사용, 답변도 클래스로 얻기
var reqData = new REQ_DATA();
reqData.ID = IDText;
reqData.AreaID = AreaIDText);
var client = new RestSharp.RestClient(URLText); //http://localhost:10101/Service
string RestAPI = string.Format("{0}", APIText); // RequestData
var request = new RestSharp.RestRequest(RestAPI, RestSharp.Method.POST);
request.RequestFormat = RestSharp.DataFormat.Json;
request.AddBody(reqData);
var queryResult = client.Execute(request);
var ResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<ServiceLogic.RES_DATA>(queryResult.Content);
댓글