Office365 API get content of ReferenceAttachment - java

I'm trying to process attachments that were added to my event and I have difficulties in loading the attachments that has the following type:
"#odata.type": "#Microsoft.OutlookServices.ReferenceAttachment"
The problem is that for usual attachments:
"#odata.type": "#Microsoft.OutlookServices.FileAttachment"
Office365 sends ContentBytes in the response with the complete content of the file. In case with the ReferenceAttachment there is no ContentBytes field in the response.
I didn't find anything useful about ReferenceAttachment in the doc:
https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#get-attachments .
However, I did succeed in finding some info in the documentation for beta version.
https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar#referenceattachment-preview
There should be SourceUrl, but I don't have it in my response either.
I really appreciate your help in finding a way to get the content of such attachments. Thanks!

I've found the solution. The reason why I wasn't able to get a source URL was the fact that this works only for beta version. I look forward to having it in a stable version, however, I will use beta one by that time.
So, to make it working, we need to change version in the path parameter to beta.
e.g.
https://outlook.office.com/api/beta/me/events/{eventId}/attachments/
Instead of:
https://outlook.office.com/api/v2.0/me/events/{eventId}/attachments/
Having done that, you will be able to see the following in your response:
"SourceUrl": "https://.../guestaccess.aspx?docid=...",
One more interesting poiunt here. If it's an Office document and you want to directly download it instead of just openning it at online editor, you can change guestaccess to download. Thus you will be able to download.

Related

Getting attachment from Github Issues using the kohsuke Github-API

I want to download attachments added to Github issue.
I'm using an API kohsuke
Usually an attachment is added to in Issue into the body of the comment.
My problem is the GHIssueComment has a body as a String. So i can not get the attachments.
I could see that the GHRepository has a method getBlob(String blobSha)
But I do not know that this is what i need, also i do not know the blobSha.

Google Drive file download via http

There is a link to Google Drive file accessible to anyone without authentication. Is there any way to download that file using just link and some sort of http client? Most of examples around are relying on Drive API and file IDs, however I'd like to stick with more lightweight approach, at the same time no parsing web page that results from http get to the url.
"If you want to share a direct link, simply change the format of the link from this:
drive.google.com/file/d/FILE_ID/edit?usp=sharing
To this:
drive.google.com/uc?export=download&id=FILE_ID
Note that you'll need to grab the file ID from the original link and append it to the end of the new link.
With the new format, any link you share will automatically download to your recipient's computer."
http://lifehacker.com/share-direct-links-to-files-in-google-drive-and-skip-th-1493813665 //Jan 2014

Java: adding attachment to the mail client launched using getDesktop().mail(URI)

In Java, how to launch the mail client along with the given file as its attachment - particularly using the method Desktop.getDesktop().mail(URI)
I am using Windows 7 and want to launch MS Outlook.
It is a good question.
Indeed the URI that sent as a parameter to method desktop.mail(URI) allows setting to, cc, bcc, subject, body and does not allow setting attachments. (see http://www.ietf.org/rfc/rfc2368.txt)
However attachments are actually specially formatted fragments of email body. Please read this for more details: http://techhelp.santovec.us/decode.htm.
This means that you can encode your binary attachment using Base64 and create email body that already contains the attachment of any generic file. I personally have not tried this but I believe it must work. Good luck.
As far as I know, it is unfortunatly not possible to specify any attachment using Desktop.mail(URI).
I've tried AlexR suggestion. It doesn't work if the file is too big because of the restriction of the number of characters in the URI.
However, it is still possible using JMAPI, though it only works on x86 platforms.
The ultimate way to make it work is using the JavaMail API, but it forces you to create your own GUI and to set the SMTP server configuration.. which is not pretty user-friendly.
If anyone as other suggestions, i'd be glad to know them.

Parse a SOAP request and modify data

I am developing an application to send a text message/sms to a user base and receive their responses. I have been given a wsdl which I have used to consume the service to sendsms using netbeans IDE .So far so good.
Now the problem is when I receive a text message a soap request is posted over to a location on our server. The request-response is as follows:
<a>http://www.csoft.co.uk/sms/api/sms_to_soap.htm</a>
I have checked the provider's sample API section but they do not have any material that does something similar.
My question is how do I parse the soap request and send the corresponding response? Also I have to check the messages and filter them for offensive/obscene content. I have the wsdl, xsd, java classes generated by netbeans, but I cant get around how to use them to achieve the goal. Any help or a pointer in the right direction would be greatly appreciated.
Thanks
Kalyan
Please search Stackoverflow and Google, there is plenty of howto around.
Even in this question, just check on the right at "related".

Is there any way to have an applet clear its own cache programmatically?

My applet currently accesses a url and prints the contents at that url. The problem is that url is fixed, but that url renders something different depending on the website's state. My applet will print a cached version of the contents at the url instead of actually retrieving the new one. I don't want the user to have to restart their browser just to get this applet to work properly and the separate_jvm tag only helps if the user refreshes the page. If I manually go into the java console and clear the classloader cache that seems to make it work.
Pretty much I want to be able to programmatically clear a JVM's cache.
After careful searching I haven not been able to find a solution, but, I was able to remember of the classic timestamp solution. If I append the timestamp to the url, even if it's not used, it will never have a cache problem.
What you need to do is set the HTTP 1.1 Cache-Control request header to no-cache. How you do that depends on the library you are using. If you are using the Apache HTTP Client, take a look at HttpRequest.setHeader(). Changing the timestamp works, but tends to clog caches with stuff that can't be reused.

Categories