<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problems adding tags to documents using webscript API in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/problems-adding-tags-to-documents-using-webscript-api/m-p/267848#M220978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to add tags to documents in Alfresco using Alfresco's webscript API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I manage to read the tags from documents using GET but when I try to POST to add a tag I get response code 500 from Alfresco and an error message in the Tomcat log including "…Expression tags is undefined…".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I guest there is something wrong with the way I send the arguments to the POST.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone managed to do this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Groovy code I use is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import java.net.URL;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import java.net.URLConnection;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import java.net.URLEncoder;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.apache.commons.codec.binary.Base64;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def urlString = "&lt;/SPAN&gt;&lt;A href="http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/47341837-0f28-4fb4-a7a1-a1a65b4c365f/tags" rel="nofollow noopener noreferrer"&gt;http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/47341837-0f28-4fb4-a7a1-a1a65b4c365f/tags&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;URLEncoder e = new URLEncoder();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def queryString = e.encode('tags=["tag1","tag2"]');&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def url = new URL(urlString);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;URLConnection connection = url.openConnection();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;String authString = "admin" + ":" + "admin";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;String authStringEnc = new String(Base64.encodeBase64(authString.getBytes()));&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;connection.setRequestMethod("POST");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connection.setRequestProperty("Authorization", "Basic " + authStringEnc);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;connection.doOutput = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def writer = new OutputStreamWriter(connection.outputStream);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;writer.write(queryString);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;writer.flush();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;writer.close();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;connection.connect();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return connection.content.text;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 05 May 2012 21:51:04 GMT</pubDate>
    <dc:creator>jacobs</dc:creator>
    <dc:date>2012-05-05T21:51:04Z</dc:date>
    <item>
      <title>Problems adding tags to documents using webscript API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/problems-adding-tags-to-documents-using-webscript-api/m-p/267848#M220978</link>
      <description>I'm trying to add tags to documents in Alfresco using Alfresco's webscript API.I manage to read the tags from documents using GET but when I try to POST to add a tag I get response code 500 from Alfresco and an error message in the Tomcat log including "…Expression tags is undefined…".I guest there</description>
      <pubDate>Sat, 05 May 2012 21:51:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/problems-adding-tags-to-documents-using-webscript-api/m-p/267848#M220978</guid>
      <dc:creator>jacobs</dc:creator>
      <dc:date>2012-05-05T21:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problems adding tags to documents using webscript API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/problems-adding-tags-to-documents-using-webscript-api/m-p/267849#M220979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think the problem is that you are posting the tags as a query string instead of posting JSON in the body of the request.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's how you'd do it in curl:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;curl -X POST -uadmin:admin "&lt;/SPAN&gt;&lt;A href="http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/637632bf-b633-472b-8696-a62e740df17c/tags" rel="nofollow noopener noreferrer"&gt;http://127.0.0.1:8080/alfresco/service/api/node/workspace/SpacesStore/637632bf-b633-472b-8696-a62e740df17c/tags&lt;/A&gt;&lt;SPAN&gt;" -H "content-type: application/json" -d @/Users/jpotts/Documents/code/tags.json&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then in tags.json, you'd have:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;["tag1","tag2"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also note that the content-type in the header needs to be set to application/json.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 23:29:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/problems-adding-tags-to-documents-using-webscript-api/m-p/267849#M220979</guid>
      <dc:creator>jpotts</dc:creator>
      <dc:date>2012-06-22T23:29:55Z</dc:date>
    </item>
  </channel>
</rss>

