コード例 #1
0
        public IRestResponse <ExecuteFiddleResponse> ExecuteFiddle(FiddleExecuteRequest request)
        {
            string apiUrl = ApiRootUrl + "/fiddles";
            var    client = new RestClient(apiUrl);

            // execute request through API
            var restRequest = new RestRequest("execute", Method.POST);

            restRequest.RequestFormat = DataFormat.Json;
            restRequest.AddBody(request);

            IRestResponse <ExecuteFiddleResponse> response = client.Execute <ExecuteFiddleResponse>(restRequest);

            return(response);
        }
コード例 #2
0
        public async Task <IRestResponse <ExecuteFiddleResponse> > ExecuteFiddleAsync(FiddleExecuteRequest request)
        {
            string apiUrl = ApiRootUrl + "/fiddles";
            var    client = new RestClient(apiUrl);

            // execute request through API
            var restRequest = new RestRequest("execute", Method.POST);

            restRequest.RequestFormat = DataFormat.Json;
            restRequest.AddBody(request);

            var cancellationTokenSource = new CancellationTokenSource();

            IRestResponse <ExecuteFiddleResponse> response = await client.ExecuteTaskAsync <ExecuteFiddleResponse>(restRequest, cancellationTokenSource.Token);

            return(response);
        }