0

I tried attaching an image as attachment to existing wiki page using RestAPI.

Followed this link http://www-10.lotus.com/ldd/appdevwiki.nsf/xpAPIViewer.xsp?lookupName=API+Reference#action=openDocument&res_title=Adding_an_attachment_to_a_wiki_page&content=apicontent

I am able to create the attachment to the wiki but it is getting corrupted when opened.Am i doing any thing wrong i sent SLug header as test.png and nonce as 1aae1966-9baf-416b-bb4c-24fe6ca7c298 and content as some binary data

Any sample examples to attach an image as attachment in WIKI page.

Thanks in advance

void
  • 36,090
  • 8
  • 62
  • 107
  • are you using the SBT? or raw connections API? it seems raw api. can you share the log of the request? – Paul Bastide Aug 10 '15 at 20:47
  • Request Headers : Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-US,en;q=0.5 Content-Length 1312752 Content-Type image/jpeg; charset=UTF-8 Cookie JSESSIONID=0000OWZ06ft8gp9guJ9MpmGs4fY:-1 Host localhost:9443 Referer https://localhost:9443/SampleSBT/PublishedWiki.html User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0 X-Requested-With XMLHttpRequest X-Update-Nonce 01c5e775-d5a0-462e-9fa5-3d4649090b26 slug sri.jpeg – Medoju Srinivas Aug 11 '15 at 16:38
  • var file = document.getElementById("wFile").files[0]; var reader = new FileReader(); reader.onload = function(e) { //passed reader.result in request } reader.readAsBinaryString(file); – Medoju Srinivas Aug 11 '15 at 18:24

1 Answers1

0

here is a curl command showing how to add attachment

curl -u "<EMAIL>:<PASSWORD>" -X POST -H "X-Update-Nonce: <NONCE>" -H "Content-Type: <CONTENT_TYPE>" -H "Slug: <FILENAME>" --data "@<FILE>" "https://<SERVER>/wikis/basic/api/wiki/<WIKI>/page/<WIKIPAGE>/feed?category=attachment"
Paul Bastide
  • 1,505
  • 4
  • 17
  • 22
  • Can you please show me the same thing in javascript.Please – Medoju Srinivas Aug 18 '15 at 06:35
  • in your sample, the data that you are adding to your Post request does not contain the file's binary content. It's just passing the name of the file. And that's the reason your file is uploaded for 242B. No issues in rest code. Please check how to upload binary data to the post request. – Vimal Dhupar Aug 31 '15 at 09:55