'rest'에 해당되는 글 2건

  1. 2020.01.20 #RestSharp Usage Example
  2. 2019.09.03 Rest Client for Visual Studio Code

    

    using RestSharp;
    using RestSharp.Authenticators;

    namespace User.Model
    {
        
        public class RestCalling
        {
            public string uri { get; set; }
            public string username { get; set; }
            public string password { get; set; }
            public string endPoint { get; set; } //"users/" + userId + "/identities.json"
            public string methodType { get; set; } //PUT, GET, POST, DELETE.

            //GET & Put & Post & Delete
            public string RestClientComm()
            {
                var _client = new RestClient(uri);
                IRestResponse result = null;
                _client.Authenticator = new HttpBasicAuthenticator(username: username, password: password);
                var request = new RestRequest(resource: endPoint, DataFormat.Json);


                switch (methodType)
                {
                    case "PUT": 
                        request.AddParameter("application/json", "\"identity\": {\"value\": \"" + "email@emailAddress" + "\"}}", ParameterType.RequestBody);
                        result = _client.Put(request);
                        break;

                    case "DELETE": 
                        result = _client.Delete(request);
                        break;

                    case "POST": 
                        request.AddParameter("application/json", "{\"identity\": {\"type\": \"email\", \"value\": \"" + "email@emailAddress"+ "\"}", ParameterType.RequestBody);
                        result = _client.Post(request);
                        break;

                    default: //GET
                        result = _client.Get(request);
                        break;

                }

                return result.Content;

            }
        }
    }

Posted by Sungyoup Han matrim

댓글을 달아 주세요

https://marketplace.visualstudio.com/items?itemName=humao.rest-client

 

REST Client - Visual Studio Marketplace

REST Client REST Client allows you to send HTTP request and view the response in Visual Studio Code directly. Main Features Send/Cancel/Rerun HTTP request in editor and view response in a separate pane with syntax highlight Send GraphQL query and author Gr

marketplace.visualstudio.com

Posted by Sungyoup Han matrim

댓글을 달아 주세요