cancel
Showing results for 
Search instead for 
Did you mean: 

Rest delete content item

erictice
Champ in-the-making
Champ in-the-making
I am using the Restful API and calling to delete items.  It appears to be deleting the item, but for some reason the status code comes back as 204 - No Content.  While technically this is true because it deleted it, shouldn't it be returning 200 - Success?  Note I am using 3.1 Labs. 

Delete call is as follows:

   @DELETE
   @Consumes("text/plain")
   @Path("/delete/{id}")
   public String deleteContentItem(@PathParam("id") String id) throws Exception{
      //DELETE /alfresco/service/api/path/{store_type}/{store_id}/{id}?includeChildren={includeChildren?}
      HttpClient client = buildClient("admin", "admin");
      DeleteMethod method = new DeleteMethod("http://localhost:8080/alfresco/service/api/node/workspace/SpacesStore/'+ id);
            
      try {
         int statusCode = client.executeMethod(method);

         if (statusCode != HttpStatus.SC_OK) {
            System.err.println("Method failed: " + method.getStatusLine());
         }
         logger.info(method.getResponseBody());

         return method.getResponseBodyAsString();
      } catch (Exception e) {
         logger.error("exception while processing message", e);
         return "Exception while getting person";
      }
   }
   
I don't know if this a bug or what alfresco expects.
2 REPLIES 2

rliu
Champ in-the-making
Champ in-the-making
You need the alf_ticket in order to perform the delete as it requires "user" authentication.

erictice
Champ in-the-making
Champ in-the-making
ok, thank you.  The api didn't mention it, so it was not obvious.