Comments (13)
Hi David,
We have verified and its working perfectly.
We sincerely appreciate your consideration and time for developing this to us so quickly...!!!
from odata-client.
Why do you care about low-level stuff like @odata.nextLink
? Just use the collections support in the API. See Collections and paging in the README.md. Can you explain your use case further?
from odata-client.
Thanks for your response and below is the use-case:
There is a service which receives request from a client and we are trying to implement paging, so that the service will send only the list of users requested by the client. As an example:
Step 1) Client send request to get the list of N users and service can get user-list as below:
OdataClientFactory
.request()
.users().top(N)
.get();
After getting response client will parse N users and extract @data.nextLink from the response.
Step 2) Client sends request to get next N users providing the @data.nextLink and service can use @data.nextLink to get next N users.
After getting response client will parse the user-list and extract @data.nextLink from the response.
Step 3) Repetition of step 2.
from odata-client.
So you're sort of proxying the Graph API for the client? @odata.nextLink just uses a skip field. You could add a counter field to the returned JSON and then get the user to pass the last counter value to the service instead of @odata.nextLink
and use
List<User> page = client.client.users().skip(counter).get().currentPage();
when they call the service. That way you are not coupled to odata metadata like @odata.nextLink
.
I could probably provide access to the @odata.nextLink
field, I just wanted to explore alternatives first.
Note also you could parse the @odata.nextLink
field that the client gives you for the skip parameter and use that in the call above.
from odata-client.
We already tried skip option(as given below) but as soon as we use skip it throws an exception(java.lang.NullPointerException). It seems skip is not supported.
List<User> users = OdataClientFactory
.request()
.users().skip(1)
.get()
.currentPage();
Ideally our use case can be implemented with below code, here top works fine but as soon as we use skip it throws exception.
List<User> users = OdataClientFactory
.request()
.users().top(200).skip(100)
.get()
.currentPage();
from odata-client.
Can you supply full stack trace? An NPE sounds like something I have to fix.
from odata-client.
By the way if top
is your attempt to control page size I don't think it works.
from odata-client.
I just tried client.users().top(200).skip(100).get().currentPage()
and like you I got an NPE. I'll fix that. However the base cause is
10:44:32.468 [main] DEBUG com.github.davidmoten.odata.client.internal.ApacheHttpClientHttpService - response text=
{
"error": {
"code": "Request_BadRequest",
"message": "'$skip' is not supported by the service.",
"innerError": {
"date": "2020-06-13T00:44:32",
"request-id": "63ed6165-729f-4753-88b9-e67399a312f5"
}
}
}
from odata-client.
In fact, digging a bit deeper I don't even have privileges:
client.users().stream().forEach(user -> System.out.println(user.getPrincipalName()));
gives an NPE (something else to fix!) and log says:
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2020-06-13T00:48:55",
"request-id": "31c91f39-f97b-4f8b-8f6f-c4c00c1a8fe9"
}
}
}
from odata-client.
Reading a bit further I think the collection returned by users().get()
must use $skipToken for pagination instead of $skip. Given this I need to rethink the advice about using skip
.
from odata-client.
Please review PR #17.
from odata-client.
I've addressed this issue now with #17.
You can specify the link for a collection like this:
List<User> users = client.users().urlOverride(url).get().currentPage();
I'll release shortly, let me know if any problems.
from odata-client.
0.1.16 released to Maven Central with #16, #17 that resolve this issue. You may wish to watch this repository to hear about future releases (which are pretty frequent lately).
from odata-client.
Related Issues (20)
- How to get partial range of content of a drive item(file) HOT 9
- DriveItem does not have the @microsoft.graph.downloadUrl property HOT 6
- Issue with Microsoft Dynamics EntityDefinitions/RelationshipDefinitions HOT 2
- Onedrive delta link, does not give top(2), but gives all changes though top is added HOT 3
- [Documentation] Authentication with OData Service HOT 7
- Cannot deserialize UnsignedByte using Serializer.deserialize HOT 5
- upload file to onedrive through createUploadSession - itemWithPath() not found HOT 4
- httpResponse of odata.client.HttpResponse put(String s, .List<RequestHeader> list, InputStream inputStream, int i,HttpRequestOptions httpRequestOptions) does not give reponse body in httpResponse.getText() as post() method gives. HOT 8
- odata\client\TestingService.class- not returning response body for patchOrPut() method. HOT 17
- post() now does a HTTP PUT HOT 4
- HttpPatch Delta<T> parameter is always Null HOT 1
- odata-client-runtime dependency on jaxb-core and jaxb-impl HOT 2
- Unable to generate a client with dynamics finance and operations metadata HOT 10
- Support "Evolvable Enumerations" with a default value HOT 5
- Hit java reserved identifier 'package' HOT 5
- Automatic mapping of "expanded" objects support? HOT 4
- Requesting an individual resource - request produced using path parameter instead of ID in brackets encoded in URL HOT 2
- How to use @odata.nextLink in graph client sdk to get the next set of messages. HOT 2
- Generated ActionRequest fails with NullPointerException if we provide null for non-required parameters. HOT 4
- odata-client-msgraph: Support for legacy extended properties HOT 33
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata-client.