通过REST API将图像插入现有的OneNote页面不起作用 [英] Inserting image into existing OneNote page via REST api not working

查看:99
本文介绍了通过REST API将图像插入现有的OneNote页面不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在创建新页面时插入图像,但是当我尝试将图像添加到现有页面中时,最终得到的是图像链接,但没有显示图像.

I can insert an image when I create a new page but when I try to add an image into an existing page I end up with an image link but no image displayed.

仅图像链接

这是请求:

Content-Disposition: form-data; name="Commands"

{
'Target':'body', 
'Action' : 'append', 
'Content' : '<div data-id=testdiv1><div>Chat message with mike</div></div>'
},
{
'Target':'#testdiv1', 
'Action' : 'insert', 
'Content' : '<img src="image1"/>'
}

Content-Type: image/png
Content-Disposition: form-data; name="image1"

imagedata....

希望有人可以看到我做错了什么,或者将我指向一个样本(最好是基于UWP但愿意查看任何内容).

Hopefully someone can see what I'm doing wrong or point me at a sample (preferably UWP based but willing to look at anything).

感谢您的帮助.

推荐答案

上面的请求有2个patch操作,首先是将div附加到主体,section操作将图像插入刚刚附加的div. 您可以尝试以下方法吗?

The request above has 2 patch actions, first is appending a div to the body and the section action is inserting an image to the div that was just appended. Can you try the following instead?

Content-Disposition: form-data; name="Commands"

{
'Target':'body', 
'Action' : 'append', 
'Content' : '<div data-id=testdiv1>
              <div>Chat message with mike</div>
              <img src="name:image1"/>
             </div>'
}

Content-Type: image/png
Content-Disposition: form-data; name="image1"

imagedata....

两个更改是:

  1. 在img标签src中添加 name:前缀.
  2. 您可以将两个补丁操作组合为一个操作.
  1. add the name: prefix in the img tag src.
  2. you can combine both patch actions into one action.

也不要忘记通常的多部分陷阱,例如确保在每个部分之间提供边界等.我们的 GitHub 示例可能会有用.

Also don't forget the usual multipart gotchas like ensuring boundary is provided between each part etc... Our GitHub sample can be useful.

这篇关于通过REST API将图像插入现有的OneNote页面不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆