Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

OneDrive for Business REST API - PUT,POST - 401 Unauthorized

$
0
0

Hi,

We've a trial version of Microsoft azure and are playing with the One drive for Business CRUD operations via the REST API from java client as per the link : https://msdn.microsoft.com/en-us/office/office365/api/files-rest-operations

After getting the token, i'm able to list any folder, download file and get attributes of a file using GET successfully.

But, the operations such as PUT, POST which are required for create folder, upload file,  rename file/folder, etc are not working. I get back "401 UnAuthorized" error.

Error Response json : 

{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":"Access denied. You do not have permission to perform this action or access this resource."}}

I set the access token in the similar way how i set for GET in the http request and i'm using jboss rest easy client for accessing the rest API

Here is a code for "Creating a folder"

ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
ResteasyProviderFactory.pushContext(javax.ws.rs.ext.Providers.class, factory);
ResteasyClientBuilder resteasyClientBuilder = new ResteasyClientBuilder().providerFactory(factory);
ResteasyClient client = resteasyClientBuilder.build();
ResteasyWebTarget target = client.target(BASE_URL + "/getByPath('/TestFolder1')");
Invocation.Builder request = target.request();
request.header("Authorization", "Bearer " + this.token);
Response response = request.put(Entity.text(""));

And as per documentation, 401 UnAuthorized error means "Required authentication information is either missing or invalid."

Am i missing any header that's supposed to be in the request/ Any other issue with the request?

Thanks,

Kathir


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>