Linked Questions

Popular Questions

Onedrive api to upload file

Asked by At

I went through many references(including onedrive api doc) but i'm unable to upload a file into onedrive using okhttp request.

The following is the code that I tried:

    try {

            boolean status;

            String url = String.format(""+step.file_name+":/content"); 
//exceptions are not coming if i mention https:// in the url. but no output is coming

            Request request = new Request.Builder()
                    .addHeader("Authorization", String.format("Bearer %s",step.getAccess_token()))

            OkHttpClient okHttpClient = new OkHttpClient();

                Response response = okHttpClient.newCall(request).execute();

                status = response.code()==200 ? true : false;

            } catch (Exception e) {
                return StepStatus.FAILURE;

When trying from postman (PUT mapping) with the url "", it is redirecting to drive but saying the file may be deleted.

But, when I'm trying to generate url with file name and hit the drive, it's Showing success but the file is not saved/uploaded in drive.

How to upload a file to onedrive from the okhttp request?

Related Questions