如何在IBM Connections中的博客帖子中添加标签? API documentation说我需要使用PUT命令更新博客文章。如果我根据文档这样做,那么我得到500内部服务器错误作为响应。尝试使用POST命令创建博客文章时也会发生同样的情况。
问题1:该命令出了什么问题?
问题2:有没有办法只添加标签而不更新博客文章的内容?
sUrl = "https://my-connect-server/blogs/%BLOGID%/api/entries/%POSTID%"
sBody = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
"<entry xmlns=""http://www.w3.org/2005/Atom"">" & _
"<id>urn:lsid:ibm.com:blogs:entry-%POSTID%</id>" & _
"<title type=""text"">Test Blog Post</title>" & _
"<summary type=""html"">new summary</summary>" & _
"<content type=""html"">new content </content>" & _
"<category term=""new-tag-1""></category>" & _
"<category term=""new-tag-2""></category>" & _
"<entry>"
Call oHttp.Open("PUT", sUrl, False)
Call oHttp.setRequestHeader("Content-Type", "application/atom+xml")
Call oHttp.send(sBody)
答案 0 :(得分:1)
原因是您没有向博客API发送完整的有效负载。您应该发送完整的博客条目,其中包含您要对XML有效负载进行的添加/减少。
我打电话给api
https://<SERVER>/blogs/5133e363-7456-4525-afe6-188960888b35/api/entries/b17182a4-7807-4adf-97c7-8ac051a3f115
我不得不修剪XML标题,所以就像这样:
<entry xml:lang="en" dir="ltr" xmlns="http://www.w3.org/2005/Atom">
<id>urn:lsid:ibm.com:blogs:entry-b17182a4-7807-4adf-97c7-8ac051a3f115</id>
<snx:communityUuid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">5133e363-7456-4525-afe6-188960888b35</snx:communityUuid>
<link href="https://<SERVER>:443/blogs/5133e363-7456-4525-afe6-188960888b35/api/entries/b17182a4-7807-4adf-97c7-8ac051a3f115" rel="edit" type="application/atom+xml">
</link>
<link href="https://<SERVER>/blogs/5133e363-7456-4525-afe6-188960888b35/entry/Test" rel="alternate" type="text/html">
</link>
<link href="https://<SERVER>:443/blogs/5133e363-7456-4525-afe6-188960888b35/feed/entrycomments/Test/atom" rel="replies" type="application/atom+xml" thr:count="0" xmlns:thr="http://purl.org/syndication/thread/1.0">
</link>
<app:collection href="https://<SERVER>:443/blogs/5133e363-7456-4525-afe6-188960888b35/api/recommend/entries/b17182a4-7807-4adf-97c7-8ac051a3f115" xmlns:app="http://www.w3.org/2007/app">
<atom:title xmlns:atom="http://www.w3.org/2005/Atom">Likes</atom:title>
<atom:category term="recommend" scheme="http://www.ibm.com/xmlns/prod/sn/collection" xmlns:atom="http://www.w3.org/2005/Atom">
</atom:category>
<app:categories fixed="yes">
</app:categories>
</app:collection>
<app:collection href="https://<SERVER>:443/blogs/5133e363-7456-4525-afe6-188960888b35/api/entrycomments/b17182a4-7807-4adf-97c7-8ac051a3f115" xmlns:app="http://www.w3.org/2007/app">
<atom:title xmlns:atom="http://www.w3.org/2005/Atom">Comment Entries</atom:title>
<app:accept>application/atom+xml;type=entry</app:accept>
<atom:category term="comments" scheme="http://www.ibm.com/xmlns/prod/sn/collection" xmlns:atom="http://www.w3.org/2005/Atom">
</atom:category>
<app:categories fixed="yes">
</app:categories>
</app:collection>
<snx:moderation status="approved" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
</snx:moderation>
<title type="text">Test</title>
<updated>2015-08-14T11:58:05.000Z</updated>
<app:edited xmlns:app="http://www.w3.org/2007/app">2015-08-14T11:58:05.000Z</app:edited>
<published>2015-08-14T11:57:44.000Z</published>
<snx:rank scheme="http://www.ibm.com/xmlns/prod/sn/recommendations" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">0</snx:rank>
<snx:rank scheme="http://www.ibm.com/xmlns/prod/sn/comment" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">0</snx:rank>
<snx:rank scheme="http://www.ibm.com/xmlns/prod/sn/hit" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">8</snx:rank>
<author>
<name>John Doe0</name>
<snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">20000395</snx:userid>
<snx:userState xmlns:snx="http://www.ibm.com/xmlns/prod/sn">active</snx:userState>
<snx:isExternal xmlns:snx="http://www.ibm.com/xmlns/prod/sn">false</snx:isExternal>
</author>
<contributor>
<name>John Doe0</name>
<snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">20000395</snx:userid>
<snx:userState xmlns:snx="http://www.ibm.com/xmlns/prod/sn">active</snx:userState>
<snx:isExternal xmlns:snx="http://www.ibm.com/xmlns/prod/sn">false</snx:isExternal>
</contributor>
<category term="test">
</category>
<category term="test2">
</category>
<app:control xmlns:app="http://www.w3.org/2007/app">
<app:draft>no</app:draft>
<snx:comments enabled="yes" days="0" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
</snx:comments>
</app:control>
<summary type="html"><p dir="ltr">Test</p></summary>
<content type="html"><p dir="ltr">Test</p></content>
</entry>
我之前添加了类别标签
<category term="test2">
</category>
我发送一个put与上面相同的api,标题为Content-Type:application / atom + xml和Method:PUT
您应该获得状态代码:200 OK