GithubHelp home page GithubHelp logo

office-365-sdk-for-java's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

office-365-sdk-for-java's Issues

DocLibClient error on call of createFile with Library parameter HTTP Error 500 -- Microsoft.SharePoint.SPQueryThrottledException

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?

Sample code required for Sharepoint service to upload the file to SP Online using java

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

Missing documentation for update of file metadata or properties with ListItemAllFields end point

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

DocLibClient error on call of delete with Library parameter HTTP Error 500 -- Microsoft.SharePoint.SPQueryThrottledException

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?

ID is not exposed

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

Gradle wrapper should be added to SCM

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.

Cannot set StartDateTime and EndDateTime parameters as String

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.

Unable to create a single day all day event

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?

sharepoint-services-java - Is it possible to get InputStream from DocLibClient?

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

DocLibClient error on call of createFolder with Library parameter HTTP Error 500 -- Microsoft.SharePoint.SPQueryThrottledException

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.

DocLibClient error on call of createFolder method HTTP Error 411 --. The request must be chunked or have a content length

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?

Unable to set date sent when creating new message in folder

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.

Trying to upload a text file but running into problems

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.

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.