json - How to interact with a REST service in C# -


i'm developing small application has interact json/rest service. easiest option interact in c# application.

i don't need have best performances, since it's tools synchronization once day, i'm more oriented toward ease of use , time of development.

(the service in question our local jira instance).

i think best way far use restsharp. it's free nuget package can reference. it's easy use , example website:

var client = new restclient("http://example.com"); // client.authenticator = new httpbasicauthenticator(username, password);  var request = new restrequest("resource/{id}", method.post); request.addparameter("name", "value"); // adds post or url querystring based on method request.addurlsegment("id", "123"); // replaces matching token in request.resource  // add http headers request.addheader("header", "value");  // add files upload (works compatible verbs) request.addfile(path);  // execute request irestresponse response = client.execute(request); var content = response.content; // raw content string  // or automatically deserialize result // return content type sniffed can explicitly set via restclient.addhandler(); restresponse<person> response2 = client.execute<person>(request); var name = response2.data.name;  // easy async support client.executeasync(request, response => {     console.writeline(response.content); });  // async deserialization var asynchandle = client.executeasync<person>(request, response => {     console.writeline(response.data.name); });  // abort request on demand asynchandle.abort(); 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -