« Teach the old dog some new tricks: Let LotusScript consume REST Services the easy way | Main| What!!! Notes 10 is coming 2018! »

Bark-bark!! The LotusScript CWebContentConsumer now support REST Service POSTs with files++

Tags: LotusScript Java
0

A couple of days ago I wrote the blog-post Teach the old dog some new tricks: Let LotusScript consume REST Services the easy way. I thank you all for the good feedback! Nice to see that some old school, classic Notes development, still got some traction Smile

Well, I was in the spirit to add some features today too!

First and foremost you now have the ability to add a payload to the PostJson, PostXML and PostHTML. By payload I mean a text string of any kind, but typically a JSON or XML. In a way you can think of it as a way of uploading a file or text together with other request headers or URL parameters.

This means that code like this;

image

… results in this;

image

Note that the payload isn't tagged a a proper multipart MIME or anything, but perhaps you can add that yourself with a combination of the new support methods for base64 encoding and decoding? You now have these additional methods;

  • EncodeStringAsBase64. Encode a string as base64. Build your own multipart XML or MIME structure, and combine that with one or more AddRequestHeaders? Or stuff the base64-encoded string as a payload directly with SetPayload.
  • EncodeFileAsBase64. Encode a whole file as base64. Remember that this hasn't been tested on huge files or anything Smile
  • DecodeBase64String. Decode a base64-encoded string back to it's textual form.
  • DecodeBase64StringToFile. Finally decode a base64-encoded string directly into a file on your disk.

I also added DownloadFileFromURL which can download any file from the specified URL and store it on disk as a file.

The demo-agents in the downloadable sample-database has been updated to use SetPayload, and the other methods are now demoed in a third agent with the name "Test Support Methods".

Happy coding!

Comments

Gravatar Image1 - Hi Robert ! I wanted to use your library in combination with HTTPS POST requests, but the function PostJsonWithAuth results in the error "already connected". I suppose this is a problem regarding the HTTPS connection. I am using Notes Client version 9.0.1 FP9 SHF 55...can you help ?
(the GET methods works fine and I can POST the same JSON string with a REST client ("Advanced REST client") also.

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)