-
Notifications
You must be signed in to change notification settings - Fork 43
csharp_client
Bruno Oliveira edited this page Feb 8, 2011
·
1 revision
Entry points are commonly defined through a resource retrieval or creation request. Restfulie allows you to use both type of entry points through its API.
Most systems will create a request retrieval entry point, which can be accessed as:
dynamic city = Restfulie.At('http://localhost:3000/cities/5.xml').Get();
After that, the xml tree can be accessed and links followed. A typical city hypermedia file would be:
<city> <name>Sao Paulo</name> <population> <size>18000000</size> <growth>10</growth> </population> <updated-at>10/01/2010</updated-at> <link rel="next_largest" href="http://localhost:3000/cities/18.xml" /> </city>
The information can be retrieved through the usual method invocations:
Console.WriteLine(city.name); Console.WriteLine(string.format("Size {0} and growth {1}", order.Population.Size, order.Population.Growth));
By default, the attributes that uses the "-" character in name will be converted to "_"
Console.WriteLine(string.format("The last update was {0}", order.Update_At))
And links can be followed as:
dynamic next_one = city.Next_largest();
Note that the client application knows what the rel attribute next_largest means, but does not know what it's value stands for (Rio de Janeiro).
In this case, you can access the http response through web_response, i.e.:
dynamic city = Restfulie.At('http://localhost:3000/cities/5.xml').Get(); Console.WriteLine(string.format("Response code {0}",city.WebResponse.StatusCode)); Console.WriteLine(string.format("The content type is {0}", city.WebResponse.ContentType));
By default, restfulie uses the following table:
- destroy, cancel and delete send a DELETE request
- update sends a PUT request
- refresh, reload, show, latest sends a GET request