OneNote的API(REST) - PATCH追加 - "必须包括一个'命令'"在已经提供的命令错误(?!) [英] Onenote API (REST) - PATCH append - "must include a 'commands'" error when Commands is already supplied (?!)

查看:172
本文介绍了OneNote的API(REST) - PATCH追加 - "必须包括一个'命令'"在已经提供的命令错误(?!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意:我是pretty确保没有错补丁查询,我不得不将其与内容型前的工作:应用/ JSON和构建JSON文件:

Note: I'm pretty sure nothing's wrong with the PATCH query, I had it working before with 'Content-type':'application/json' and a constructed json file:

[
  {
  'target':'|TARGET_ID|',
  'action':'append',
  'content':'|HTML|'
  }  
]

有关的这个目的,所提供的报头(认证承载是正确的,将省略)

For the purposes of this, the header supplied (authentication bearer is correct and will be omitted)

'Content-type':'multipart/form-data; Boundary=sectionboundary' 

(注:边界= sectionboundary是在同一直线上)

(note: Boundary=sectionboundary is in the same line)

如果试图传递了以下机身作为一个补丁结果
     https://www.onenote.com/api/v1.0 /页/ | GUID | /内容
 返回
     code:20124,消息:一个多部分PATCH请求必须包括含有补丁行动JSON结构的'命令'的一部分。

Attempting to pass the following body as a PATCH to
https://www.onenote.com/api/v1.0/pages/|GUID|/content returns a "code":"20124","message":"A multi-part PATCH request must include a 'commands' part containing the PATCH action JSON structure." :

--sectionboundary
Content-Disposition: form-data; name="Commands"
Content-Type: application/json
[
  {
  'target':'|TARGET_ID|',
  'action':'append',
  'content':'|HTML|'
  }  
]

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

|BINARY_IMAGE_DATA|

--sectionboundary--

正如你所看到的,有一个命令部分了。使用小型大写字母命令没有帮助,并正确的语法应该是命令按OneNote的开发中心文档。

As you can see, there's a Commands section already. Using smallcaps 'commands' doesn't help, and the correct syntax should be "Commands" as per the OneNote Dev Center documentation.

PS:| TARGET_ID | |全文| | GUID |和| BINARY_DATA |被替换为在运行时正确的内容。由于保密的限制,事实上,你可以使用一个不同的模式,比我做的,多久| BINARY_IMAGE_DATA |实际上是,我不会让实际输入,除非需要解决的问题。

PS: |TARGET_ID| |HTML| |GUID| and |BINARY_DATA| are replaced with the correct content at runtime. Due to privacy constraints, the fact that you may use a different schema than I do, and how long |BINARY_IMAGE_DATA| actually is, I will not show the actual input unless required to solve the problem.

想知道如果我错过了什么 - 在此先感谢

Would like to know if I missed anything - thanks in advance.

PPS:是的,我知道我省略内部img标签|全文|某处。它不应该有任何与code 20124,如果我听错了,应该全部退还另一回事。

PPS: Yes, I realize i've omitted the img tag inside |HTML| somewhere. It shouldn't have anything to do with code 20124, and if I got it wrong should return another thing entirely.

推荐答案

根据调查您共享的请求信息,我可以证实,补丁请求你提供不符合您的贴头信息相关的部分引用。
该相关PATCH请求显示为仅具有媒体类型text / html的,而不是应用/ JSON的单一部分的多部分请求。能否请您检查并确认您的请求的内容?
让我们继续讨论这个问题的电子邮件。如果你仍然面临调用API的问题,请写信给我在machandw@microsoft.com

Based on investigating the request information you shared, I can confirm that the PATCH request referenced as part of the correlation you provided does not match your posted header information. The correlated PATCH request shows up as a multi-part request with only a single part that has Media Type "TEXT/HTML" and not "Application/JSON". Can you please check and confirm your request content ? Let us continue to discuss this on email. If you still face issues calling the API, please write to me at machandw@microsoft.com

问候,
马诺

这篇关于OneNote的API(REST) - PATCH追加 - "必须包括一个'命令'"在已经提供的命令错误(?!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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