问题
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.
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?
来源:https://stackoverflow.com/questions/29515578/onedrive-for-business-rest-api-put-post-401-unauthorized