Comments (13)
Hi David,
I tested with 0.1.53 and the fix works as expected. I am now able to get the stream provider of contents of a drive item using
graphService .drives(driveId) .items(itemId) .metadataFull() .get() .getContent();
Thanks a lot.
from odata-client.
By the way, the need to specify metadataFull() before getting a stream is an annoying gotcha that will probably bite lots more people. I'm thinking I might default to full metadata for any media entity or entity with a stream property. I'll raise a PR for this soon, comments welcome.
from odata-client.
Please show the stack trace of the NullPointerException.
from odata-client.
Also put on debug logging so we can see the metadata returned with the Drive Item (I want to see the json payloads).
from odata-client.
Looking at https://docs.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0 it appears that microsoft in their wisdom (!!!) have chosen to use non-standard metadata fields for the download url (@microsoft.graph.downloadUrl
). Seeing the DriveItem json returned (or print out item.getUnmappedFields().entrySet()) would be great, thanks.
from odata-client.
You can try your code again with 0.1.53-SNAPSHOT if you like (build latest master branch) as I've added a bit of a bandaid to use @microsoft.graph.downloadUrl
if it exists (and the expected OData metadata field of [email protected]
is not present).
from odata-client.
Note also from README.md: https://github.com/davidmoten/odata-client#streams (add .metadataFull() before calling .get())
from odata-client.
Hi David,
I tried with the 0.1.53-SNAPSHOT but still facing same issue (stack trace at the end). Attaching the Drive Item json for your ref.
driveItem.txt
When I tried calling .metadataFull() before calling get(), I get a different error though. Adding it seems to add an extra /$value at the end of the request url :
getStream returned HTTP 400
url=https://graph.microsoft.com/v1.0/drives('b%219BWQkwb6BU-FGYNtnMEvuM_f_Djq5I9MvNVLQbVWhmdpm4AZrhScTbapjoB5OoNJ')/items('01OKI7IIFLATICNLEZLVFKWT5F7TT7C2E4')/content/%24value
headers=[]
response:
{"error":{"code":"BadRequest","message":"The request URI is not valid. The segment 'content' must be the last segment in the URI because it is one of the following: $ref, $batch, $count, $value, $metadata, a named media resource, an action, a noncomposable function, an action import, a noncomposable function import, an operation with void return type, or an operation import with void return type.","innerError":{"date":"2021-04-28T12:16:40","request-id":"77c43951-83e2-4f99-a626-e072c1b541eb","client-request-id":"77c43951-83e2-4f99-a626-e072c1b541eb"}}}
Here is the stack trace of the null pointer exception without .metadataFull()
java.lang.NullPointerException: null
at com.github.davidmoten.odata.client.Path.addSegmentDelimiter(Path.java:52) ~[odata-client-runtime-0.1.49.jar:na]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ org.springframework.security.web.server.authorization.AuthorizationWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.authorization.ExceptionTranslationWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.authentication.logout.LogoutWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.savedrequest.ServerRequestCacheWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.context.SecurityContextServerWebExchangeWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.authentication.AuthenticationWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.context.ReactorContextWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.header.HttpHeaderWriterWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.config.web.server.ServerHttpSecurity$ServerWebExchangeReactorContextWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.security.web.server.WebFilterChainProxy [DefaultWebFilterChain]
|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP GET "/api/o365/v1/drives/b!9BWQkwb6BU-FGYNtnMEvuM_f_Djq5I9MvNVLQbVWhmdpm4AZrhScTbapjoB5OoNJ/items/01OKI7IIFLATICNLEZLVFKWT5F7TT7C2E4/content" [ExceptionHandlingWebHandler]
Stack trace:
at com.github.davidmoten.odata.client.Path.addSegmentDelimiter(Path.java:52) ~[odata-client-runtime-0.1.49.jar:na]
at com.github.davidmoten.odata.client.Path.addSegment(Path.java:42) ~[odata-client-runtime-0.1.49.jar:na]
at com.github.davidmoten.odata.client.internal.RequestHelper.createStreamForEdmStream(RequestHelper.java:463) ~[odata-client-runtime-0.1.49.jar:na]
at odata.msgraph.client.entity.DriveItem.getContent(DriveItem.java:499) ~[odata-client-msgraph-0.1.49.jar:na]
from odata-client.
Thanks for the details @AmudhaNila. I'm relieved to see the [email protected]
field and $value
should not be appended to a stream property (only media entities) so I'll fix that. I'll also fix the NPE. I assume the [email protected]
only turns up when .metadataFull()
is added?
from odata-client.
I've applied the fixes in PR # 128 which has been merged.
Can you build 0.1.53-SNAPSHOT again from master and try that call again please?
from odata-client.
I've released 0.1.53 with these fixes, can you try that version please?
from odata-client.
I've also raised microsoftgraph/microsoft-graph-docs-contrib#3582 to fix the graph documentation.
from odata-client.
No worries. Thanks for the report. I hadn't bumped into stream properties yet in my own use cases so was an untested path.
from odata-client.
Related Issues (20)
- NPE when running odata-client-maven-plugin through Java 11 HOT 10
- Batch requests? HOT 6
- Create client for Graph v1.0 behind a proxy doesn't work HOT 6
- 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
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.