-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve single objects #24
Comments
Also, fixed a deprecated NuGet parameter (PackageLicenseUrl).
… resources. Now it looks for embedded resources by matching on the self link. If there are no matches, it follows the link (via a HTTP request).
Hi, i see there is some progress going on. |
…ave stopped producing coverage reports.
…pears to have stopped producing coverage reports.
Hi Jürgen, I'm very sorry for not responding sooner. I took a look a couple of weeks ago, but I've been crazy busy lately. Thanks for getting in touch. I hope you're finding this library useful. I was about to respond to your query, when I noticed a bug in the code. I've added a fix, which is unit-tested, but I haven't gotten a chance to fully integration-test it. The patch version is available on pre-release (2.3.150-alpha). Let me know if you encounter any issues. To answer your first question; I think you need to add the "users" link, as per the example below. That instructs the HalClient how to retrieve a specific resource. First it will look in _embedded, using the href from _links to resolve the individual resource. Otherwise, it will look follow the href in _links. {
"_embedded" : {
"users" : [ {
"id" : 2,
"name" : "asddf",
"_links" : {
"self" : {
"href" : "http://localhost:8080/users/2"
},
"user" : {
"href" : "http://localhost:8080/users/2"
},
"address" : {
"href" : "http://localhost:8080/users/2/address"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/users{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://localhost:8080/profile/users"
},
"users" : {
"href" : "http://localhost:8080/users/{id}",
"templated" : true
}
},
"page" : {
"size" : 20,
"totalElements" : 1,
"totalPages" : 1,
"number" : 0
}
} Here's an example query: var user =
client
.Root("https://your-domain.com/api/") // navigate to the root of your API
.Get(rel: "users-query", parameters: new {page = 0, size = 10}) // navigate to the paged users resource
.Get(rel: "users", new {id = 2}) // navigate to user with ID=2; HalClient will look first in _embedded, otherwise it will follow the "users" href
.Item<UserDto>() // deserialise to object of type IResource<UserDto>
.Data; // return UserDto object To answer your second question; if the HTTP request is unsuccessful, it will throw an If you're happy with this fix, could you take a look at the PR I raise, please? #25 Cheers, |
Hi, i found your library and the api looks very nice for consuming hal based rest apis.
I have two questions regarding the api usage:
My Resource:
How do i get the user resource with id 2 without fetching everything and traverse through the result? I am looking for a single http request solution to get /users/2 into my user dto.
How do i check for all the http error codes and messages e.g.:
/users/3 => 404 or with detailed json result.
The text was updated successfully, but these errors were encountered: