Works with JSON only! XML related features are commented out.
~/dev/OK/UnitySample $ cat Assets/smcs.rsp -define:DEBUG;UNITY To build for Unity, compile with:
/Applications/Unity/Unity.app/Contents/Frameworks/Mono/bin/gmcs -target:library -define:UNITY -r:/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll -recurse:RestSharp/*.cs -out:RestSharp.dll Please use the Google Group for feature requests and troubleshooting usage.
- Supports .NET 3.5+, Silverlight 4, Windows Phone 7, Mono, MonoTouch, Mono for Android
- Easy installation using NuGet for most .NET flavors
- Automatic XML and JSON deserialization
- Supports custom serialization and deserialization via ISerializer and IDeserializer
- Fuzzy element name matching ('product_id' in XML/JSON will match C# property named 'ProductId')
- Automatic detection of type of content returned
- GET, POST, PUT, HEAD, OPTIONS, DELETE supported
- Other non-standard HTTP methods also supported
- oAuth 1, oAuth 2, Basic, NTLM and Parameter-based Authenticators included
- Supports custom authentication schemes via IAuthenticator
- Multi-part form/file uploads
- T4 Helper to generate C# classes from an XML document
varclient=newRestClient("http://example.com");// client.Authenticator = new HttpBasicAuthenticator(username, password);varrequest=newRestRequest("resource/{id}",Method.POST);request.AddParameter("name","value");// adds to POST or URL querystring based on Methodrequest.AddUrlSegment("id","123");// replaces matching token in request.Resource// add parameters for all properties on an objectrequest.AddObject(object);// or just whitelisted propertiesrequest.AddObject(object,"PersonId","Name", ...);// easily add HTTP Headersrequest.AddHeader("header","value");// add files to upload (works with compatible verbs)request.AddFile(path);// execute the requestIRestResponseresponse=client.Execute(request);varcontent=response.Content;// raw content as string// or automatically deserialize result// return content type is sniffed but can be explicitly set via RestClient.AddHandler();RestResponse<Person>response2=client.Execute<Person>(request);varname=response2.Data.Name;// or download and save file to diskclient.DownloadData(request).SaveAs(path);// easy async supportclient.ExecuteAsync(request, response =>{Console.WriteLine(response.Content);});// async with deserializationvarasyncHandle=client.ExecuteAsync<Person>(request, response =>{Console.WriteLine(response.Data.Name);});// abort the request on demandasyncHandle.Abort();