ews-managed-api icon indicating copy to clipboard operation
ews-managed-api copied to clipboard

ExportItems and UploadItems

Open LukeMarlin opened this issue 9 years ago • 17 comments

Hi guys,

Do you intend to implement these two methods in EWS managed API, or will we have to stick with web calls ?

LukeMarlin avatar Jun 18 '15 09:06 LukeMarlin

No plan to do this at this time, but if you want to give it a shot you are more than welcome.

dclaux avatar Jun 18 '15 18:06 dclaux

Hello, i'm going to implement it. (i'm luke co-worker)

Just to be sure i need to :

  • Implement Responses
  • Implement Requests
  • add new functions to service

Do this sounds right ?

XavierDa avatar Jun 19 '15 09:06 XavierDa

Any insight from you @dclaux @vboctor ?

LukeMarlin avatar Jun 22 '15 10:06 LukeMarlin

@XavierDa Yes, that sounds about right. Looking forward to looking at your changes.

dclaux avatar Jun 22 '15 16:06 dclaux

Hello, i finished implementing it, but i have a small problem.

It seems that exportItems change ItemIds (can't find any of the itemids i sent in the result), Is there any way to find a link between them ?

XavierDa avatar Jun 22 '15 16:06 XavierDa

One caveat - The typical use case for UploadItems is read data from somewhat large files (as opposed to in-memory buffers) or from a database field. So the EWS Managed API's implementation of UploadItems should stream the data right from its source and serialize it by chunks, so that there is no need to load a full copy of all the data in memory. You can take a look at how file attachments are handled to see an example of the how the API does this.

dclaux avatar Jun 22 '15 16:06 dclaux

ExportItems shouldn't change any Id. It's just a dump of what's in a mailbox.

dclaux avatar Jun 22 '15 16:06 dclaux

So are you saying that the Ids you get in ExportItems' response aren't the same as the ones you passed in the request? Sounds really weird to me. That said the items in the response should be in the same order as those in the request, so you can match based on ordering.

dclaux avatar Jun 22 '15 16:06 dclaux

Ok found my error. I had a misplaced new ItemId.

For uploadItems... i will check how it's done for file attachement and try to get a similar solution. Right now my solution for exportItem returns a byte[] for data, maybe it should use a Stream too ? (so it's easier to implement export => upload solutions ?)

XavierDa avatar Jun 22 '15 16:06 XavierDa

Yes, ExportItems should also use streams.

dclaux avatar Jun 22 '15 17:06 dclaux

Thinking more about this - ExportItems needs to be passed a callback method that lets the developer specify the stream for each item in the response. Either that, or introduce an "ExportManager" class that encapsulates the entire logic and exposes an event that lets developers specify the destination stream for each item. I can think of two main ways a developer might want to store what ExportItems produces: 1) one file/database row/field per item, or 2) a single file that stores all items. I think the API should make it easy to do either.

dclaux avatar Jun 22 '15 17:06 dclaux

How far did you get with this? @XavierDa

Biztactix-Ryan avatar May 24 '19 12:05 Biztactix-Ryan

We have a working version here, but we never manage to make a PR due to some slight hiccups on our side.

if you want this you can get it from this pull request https://github.com/OfficeDev/ews-managed-api/pull/109

XavierDa avatar May 24 '19 12:05 XavierDa

@XavierDa , are we sure it is working?

I can get the data without issue, but the UploadItem doesn't seem to do anything on the target mailbox / service

image

Source mailbox Inbox:

image

Target mailbox Inbox:

image

jrouzies-fr avatar Jan 30 '20 11:01 jrouzies-fr

Did you check your uploaditem returns ? it may succeed globally but each item may fail.

XavierDa avatar Jan 30 '20 11:01 XavierDa

(fix for my issue in Update2 below)

Did you check your uploaditem returns ? it may succeed globally but each item may fail.

Indeed my bad, there is an error in the response, indicating malformed ID:

image

Is it possibles IDs from Exchange Online are incompatible with OnPremise ones?


Update: tried from OnPrem to OnPrem, same issue. Realized ItemToUpload ID was not filled, don't know if it was on purpose. But even filling it still shows the issue:

image


Update 2: I made further tests, and I created a custom folder, and search for that specific folder ID before using it in the itemToUpload. It worked.

It seems what is causing the issue is the "WellKnownFolderName.Inbox".

image

To conclude: make sure you get the ID by binding the folder in the destination service, not just by specifying a WellKnownFolder in the item to upload.

jrouzies-fr avatar Jan 30 '20 11:01 jrouzies-fr

Hi, I am also using the ExportItems and UploadItems to backup and restore items in outlook. Both are working, however when I use the CreateAction Update to update an existing item, the "pin/unpin" and "mark as read/unread" property of the item in UI is not updated. Though these fields are updated when I use CreateNew as long as the item does not exist in Inbox. Does anyone encountered this issue or anyone who knows how to fix it? Thanks!

aldrinbucagahsay avatar Sep 30 '20 11:09 aldrinbucagahsay