officedev / office-365-sdk-for-java Goto Github PK
View Code? Open in Web Editor NEWOffice 365 client for Java
License: Other
Office 365 client for Java
License: Other
Similar to issue #18, creating a file with the method
ListenableFuture<FileSystemItem> handle = client.createFile("zyva.txt", "Filestore", true,
"Hello".getBytes("UTF-8"));
will create the file in SharePoint but fails with the error:
java.util.concurrent.ExecutionException: java.lang.Exception: Invalid status code 500: {"error":{"code":"-2147024860, Microsoft.SharePoint.SPQueryThrottledException","message":{"lang":"en-US","value":"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."}}}
at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
Creating the file with the Add method from the reference document works well, so why is this is not implemented in this library?
Hi,
As an enhancement to the existing set of functionality provided by this library, it would be very helpful to implement the GetFileById end point. Also it would not hurt to document this end point in the REST API documentation for SharePoint online.
Many thanks in advance
Hello,
I am new to this API and i am trying to use this API to upload the file to Sharepoint online folders.
I cannot find any User guide to use this API as well. I cannot understand how to use this API with Java.
Kindly someone provide me the sample code to understand this Sharepoint service part in this API.
Thanks,
RameshKumar Mathiyazhgan
Is the SDK going to be updated to support Outlook API v2.0 so that the user photo API (https://msdn.microsoft.com/en-us/office/office365/api/photo-rest-operations) can be used?
Hi,
As an enhancement to the existing set of functionality provided by this library, it would be very helpful to implement the ListItemAllFields end point.
Many thanks in advance
Hi
I am developing an web application in Java..I could not find any sample code or tutorial to do the calendar sync function...kindly guide me ASAP
as the title says: Does this library work for Sharepoint On-Prem?
Thanks
Hi,
Contrary to the issue #25 where the implementation for the ListItemAllFields endpoint is missing but well documented and is therefore trivial to implement; updating properties of a file is not documented at all.
The ListItemAllFields endpoint is listed as read only method in the Files section of the SharePoint REST API documentation. The Lists section does not specifically mention ListItemAllFields.
The following discussion is helpful to get started: https://sharepoint.stackexchange.com/questions/160779/sharepoint-rest-api-c-update-document-metadata
Regards
Past the issue #17, delete a folder or file with the method:
ListenableFuture<Void> handle = this.client.delete(path, library);
fails with the error:
Caused by: java.lang.Exception: Invalid status code 500: {"error":{"code":"-2147024860, Microsoft.SharePoint.SPQueryThrottledException","message":{"lang":"en-US","value":"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."}}}
at com.microsoft.services.sharepoint.OfficeClient$2.onSuccess(OfficeClient.java:195)
at com.microsoft.services.sharepoint.OfficeClient$2.onSuccess(OfficeClient.java:181)
Using the endpoint suggested in the SharePoint REST reference document works well, so why is this is not implemented in this library?
There are important files that Microsoft projects should all have that are not present in this repository. A pull request has been opened to add the missing file(s). When the pr is merged this issue will be closed automatically.
Microsoft teams can learn more about this effort and share feedback within the open source guidance available internally.
With the Java SDK, the entity ids do not seem to be exposed. For example, with the following code to create a simple group:
private static void addOneGroup(OrcCollectionFetcher<Group, GroupFetcher, GroupCollectionOperations> groupsFetcher)
throws Exception {
Group g = new Group();
g.setDescription("Group created via REST API");
//Required
g.setDisplayName("Test Group");
//Required
g.setMailNickname("test_nick");
//Required
g.setMailEnabled(false);
//Required
g.setSecurityEnabled(true);
logger.info("Creating test group...");
Object o = groupsFetcher.add(g);
}
the Group::getObjectId
always returns null and there is no other "id" properties on the Group
or DirectoryObject
. Without the id being exposed, how could one delete or update entities via this SDK API? Since the update
and delete
methods are only available via OrcEntityFetcher
and to obtain it, requires to pass the id value to getById
Ping @marcote
Any idea when you can support freebusy of the attendees ?
The Gradle docs say:
The wrapper is something you should check into version control. By distributing the wrapper with your project, anyone can work with it without needing to install Gradle beforehand.
So I think the lines regarding the Gradle wrapper should be removed from the .gitignore file and the wrapper should be added to the repository.
I try to execute following code:
final List<Event> events = graphServiceClient
.getUsers()
.getById(<user_id>)
.getCalendarView()
.addParameter("StartDateTime", new StringBuilder("2016-03-08T00:00:00.0000000"))
.addParameter("EndDateTime", new StringBuilder("2016-03-08T23:10:00.0000000"))
.read()
.get();
and I get the error:
Response status: 400
Response content: {
"error": {
"code": "ErrorInvalidParameter",
"message": "The value ''2016-03-08T00:00:00'' of parameter 'StartDateTime' is invalid.",
"innerError": {
"request-id": "4678f2fc-de3e-401d-8989-d66462c8ed0d",
"date": "2016-03-08T12:09:48"
}
}
}java.util.concurrent.ExecutionException: com.microsoft.services.orc.core.OrcException: Response status: 400
When I dug into the code it occurred that String params are wrapped into single quotes '
by following method in class com.microsoft.services.orc.core.Helpers
private static String toODataURLValue(Object o) {
if (o instanceof String) {
return "'" + o + "'";
}
if (o instanceof Calendar) {
return CalendarSerializer.serialize((Calendar) o);
}
return o.toString();
}
I don't know why is this logic, it seems incorrect here, or at least for date params. I workedaround it by using StringBuilder:
.addParameter("StartDateTime", new StringBuilder("2016-03-08T00:00:00.0000000"))
.addParameter("EndDateTime", new StringBuilder("2016-03-08T23:10:00.0000000"))
and it work fine.
Can you please add some documentation on whether this api is in beta and if so when it will be ready for production ?
Also some basic help docs on how to get started to use this api . For e.g connecting to office365 using oauth, retrieving outlook calendar events etc.
It seems impossible to create a single day (24 hour) all day event.
If I try and set the start/end dates to be the same then I get error:
"The duration of an event marked as All day must be at least 24 hours."
If I set the end date to be start date + 1 day then the date spans 2 days in the Office 365 calendar.
If I try and set the end date to be start date - 1 second then I get an error saying that all day events must have their times set to midnight.
I've set the timezone to "Greenwich Standard Time" for the start and end time zone.
Is there something I'm missing or is it just not possible?
Hi.
I'm investigating if this SDK might be a good choice for my organization for sharepoint file handling via REST.
I'm using the DocLibClient from sharepoint-services-java to handle files and folders on a sharepoint site. When I'm downloading a file, I can see no other option than to call getFile which loads the entire file contents into a byte arrray. This of course consumes a lot of memory if it is a large file.
Is it possible to create a method with the following signature?
public ListenableFuture<InputStream> getFile(String path) {...}
This would allow us to handle the download from the stream in a convenient way.
Regards
Daniel Rehnberg
After resolving issue #17 the next problem is creating a folder by specifying a Library:
ListenableFuture<FileSystemItem> handle = client.createFolder("this/is/a/revolution", "Filestore");
... the folder gets created in SharePoint, but the call fails with:
java.util.concurrent.ExecutionException: java.lang.Exception: Invalid status code 500: {"error":{"code":"-2147024860, Microsoft.SharePoint.SPQueryThrottledException","message":{"lang":"en-US","value":"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator."}}}
at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
The error stems from the search following specified when a library is provided:
if (library == null) {
postUrl = getSiteUrl() + "_api/files";
} else {
postUrl = getSiteUrl() + String.format("_api/web/lists/GetByTitle('%s')/files", urlEncode(library));
}
This search is too wide or not specific enough it seems.
Hi,
Using:
<dependency>
<groupId>com.microsoft.services</groupId>
<artifactId>sharepoint-services-java</artifactId>
<version>1.0.0</version>
</dependency>
to create a folder:
DocLibClient client = newClient(); // authenticate and create client;
ListenableFuture<FileSystemItem> handle = client.createFolder("sample", "Filestore");
Fails with the following error:
java.util.concurrent.ExecutionException: java.lang.Exception: Invalid status code 411: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
at mytest.samples.sharepoint.CreateFolderTest.testCreateFolder(CreateFolderTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.Exception: Invalid status code 411: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>
at com.microsoft.services.sharepoint.SharePointClient$1.onSuccess(SharePointClient.java:105)
at com.microsoft.services.sharepoint.SharePointClient$1.onSuccess(SharePointClient.java:86)
at com.google.common.util.concurrent.Futures$6.run(Futures.java:1319)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:457)
at com.google.common.util.concurrent.ExecutionList.executeListener(ExecutionList.java:156)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:145)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.microsoft.services.sharepoint.http.NetworkRunnable.run(NetworkRunnable.java:66)
at java.lang.Thread.run(Thread.java:745)
The error occurs in the method SharePointClient.getFormDigest()
. Logs from sharepoint-services-java library output:
2017-05-10T22:22:36,883 DEBUG mytest.samples.sharepoint.CreateFolderTest - Created DocLibClient
2017-05-10T22:22:36,886 DEBUG mytest.samples.sharepoint.CreateFolderTest - Generate request for getFormDigest
2017-05-10T22:22:36,886 DEBUG mytest.samples.sharepoint.CreateFolderTest - URL: https://mycompany.sharepoint.com/sites/mysite/_api/contextinfo
2017-05-10T22:22:36,886 DEBUG mytest.samples.sharepoint.CreateFolderTest - VERB: POST
2017-05-10T22:22:36,886 DEBUG mytest.samples.sharepoint.CreateFolderTest - Header Authorization: Bearer skipped
2017-05-10T22:22:36,887 DEBUG mytest.samples.sharepoint.CreateFolderTest - Header X-ClientService-ClientTag: SDK-JAVA
2017-05-10T22:22:36,887 DEBUG mytest.samples.sharepoint.CreateFolderTest - Header Accept: application/json;odata=verbose
2017-05-10T22:22:36,887 DEBUG mytest.samples.sharepoint.CreateFolderTest - Header Content-Length: 0
Could this be addressed, please?
Hi guys, when support for Outlook Push Notifications
will be added?
I am using Outlook push notification API to receive events from calendar.
When an event is deleted from recurring event, I get notification with type 'updated'. But i do not get the information of the deleted event. How can i get the information about the deleted event.
Why isnt this on maven yet?
Hi,
I am using MeetingMessageType property in my code and I noticed that there is a typo in MeetingMessageType = 'MeetingTenativelyAccepted', where it should be 'MeetingTentativelyAccepted'
Please let me know if it is a valid concern.
It appears that calling setDateTimeSent (or setDateTimeReceived) on a Message has no effect when creating a new message in a folder.
The new message is created in the folder and is marked as a draft and not sent. Calling Message.setIsDraft (false) has no effect either.
I used the following test code (shortened):
Message message = new Message ();
java.util.Calendar sentCal = new GregorianCalendar ();
sentCal.setTime (new Date ());
sentCal.setTimeZone (TimeZone.getTimeZone ("GMT"));
message.setDateTimeSent (sentCal);
message.setIsDraft (false);
userFetcher.getFolder (folderId).getMessages ().add (message).get (60, TimeUnit.SECONDS);
All the other information in the message is appearing correctly.
I am able to create a text file using this sample from the Android API:
GraphServiceClient client = ApplicationContext.getGraphServiceClient();
String filename = UUID.randomUUID().toString() + ".txt";
Item newFile = new Item();
newFile.setType("File");
newFile.setName(filename);
Item addedFile = client.getUsers().getById("[email protected]").getFiles().add(newFile).get();
client.getUsers().getById("[email protected]")
.getFiles().getById(addedFile.getId())
.asFile().getOperations().uploadContent("My Content".getBytes()).get();
...but when I view the file the contents, they look like this:
{"contentStream":"TXkgQ29udGVudA=="}
I also tried using the FileClient class but I just get a http 500 server error when I try and add a string. The file is created on my OneDrive account.
FilesClient client = ApplicationContext.getFilesClient();
client.getFiles().getById(addedFile.getId()).asFile().putContent("My Content".getBytes()).get();
Any help/suggestions would be very appreciated.
Hi,
Similarly to issue #18, calling getFileSystemItem(String path, final String library) fails with a 500 error. The fix is quite easy to implement, so please make a new release of this library.
Many thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.