Comments (4)
Tried below code with odataClientFactory . Throws invalid request error.
graphService
.users(userId)
.drive().root()
.createUploadSession(DriveItemUploadableProperties.builder().build().withName("abc.txt"), true)
.get()
Error:Bad Request
{
"timestamp": "2021-07-16T07:32:52.588+00:00",
"path": "/api/o365/v1/drives/bisht%40hpdatapro.onmicrosoft.com/createUploadSession",
"status": "BAD_REQUEST",
"error": "Bad Request",
"requestId": "efe58cdf-2",
"statusCode": 400,
"message": "responseCode=400 from url=https://graph.microsoft.com/v1.0/users/bisht%40hpdatapro.onmicrosoft.com/drive/root/createUploadSession, expectedResponseCode in [200, 299], message=\n{"error":{"code":"invalidRequest","message":"Invalid request","innerError":{"date":"2021-07-16T07:32:26","request-id":"97973f78-9c54-4624-a8cd-72b1f18f06a6","client-request-id":"97973f78-9c54-4624-a8cd-72b1f18f06a6"}}}"
}
from odata-client.
Ok, thanks. The use of a request like POST /drive/root:/{item-path}:/createUploadSession
is not specified in the OData metadata and I'm not sure if it was what it would look like. I'll have a think about it. In the meantime as a workaround use a custom request.
from odata-client.
Thanks David. Will try for custom request.
Looking for uploading files on root and also under any folder in a drive.
POST /drives/{driveId}/items/{itemId}:/{fileName}:/createUploadSession
POST /drive/root:/{fileName}:/createUploadSession
from odata-client.
Hi David,
I tried to create upload session using below post method.
_com.github.davidmoten.odata.client.HttpService public com.github.davidmoten.odata.client.HttpResponse post(String url, java.util.List<com.github.davidmoten.odata.client.RequestHeader> requestHeaders, String content, com.github.davidmoten.odata.client.HttpRequestOptions options)
Maven: com.github.davidmoten:odata-client-runtime:0.1.59
I'm receiving response like below from httpResponse.getText() here:
"{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession\",\"expirationDateTime\":\"2021-07-22T17:25:42.05Z\",\"nextExpectedRanges\":[\"0-\"],\"uploadUrl\":\"https://xyz-my.sharepoint.com/personal/user_xyz_onmicrosoft_com/_api/v2.0/drives/{driveid}/items/{itemid}/uploadSession?guid='....'&overwrite=True&rename=False&dc=0&tempauth=......\"}"
And then, I'm trying to upload content using upload url received from above method. I'm using below put method to execute the uploadurl. But i receive { "responseCode": 202, "bytes": null, "text": null } in httpResponse.
com.github.davidmoten.odata.client.HttpService public abstract com.github.davidmoten.odata.client.HttpResponse put(String s,
java.util.List<com.github.davidmoten.odata.client.RequestHeader> list, java.io.InputStream inputStream, int i, com.github.davidmoten.odata.client.HttpRequestOptions httpRequestOptions)
Maven: com.github.davidmoten:odata-client-runtime:0.1.59
As per documentation, i would need to get response as below:
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"expirationDateTime": "2015-01-29T09:21:55.523Z",
"nextExpectedRanges": ["26-"]
}
OR
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "912310013A123",
"name": "largefile.vhd",
"size": 128,
"file": { }
}
Can you please check on why httpResponse.getText() is null in the response. Also please suggest if any alternative, as i would need the actual reponse text.
Thanks,
Pavani.
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
- 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.