GithubHelp home page GithubHelp logo

Comments (4)

Pavani-Y avatar Pavani-Y commented on June 7, 2024

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.

davidmoten avatar davidmoten commented on June 7, 2024

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.

Pavani-Y avatar Pavani-Y commented on June 7, 2024

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.

Pavani-Y avatar Pavani-Y commented on June 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.