Cannot delete tags. I'm using API Rest Alfresco
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 08:06 AM
Hi,
I can´t delete document tags and Alfresco tags using APIRest.
I`m creating Request Delete with the following url:
String url = server + "/alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket;
And the error is:
Remote Server Error (405) Method not allowed.
- The Server, nameTag and ticket are correct.
I need help!! Thanks!
I can´t delete document tags and Alfresco tags using APIRest.
I`m creating Request Delete with the following url:
String url = server + "/alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket;
And the error is:
Remote Server Error (405) Method not allowed.
- The Server, nameTag and ticket are correct.
I need help!! Thanks!
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 10:09 AM
I have tested it ,it works fine,there must be something wrong with your code. Following is my test code
HttpClient client = new HttpClient(); client.getState().setCredentials( new AuthScope("localhost", 8080, "Alfresco"), new UsernamePasswordCredentials("admin", "admin")); String apiurl = "http://localhost:8080/alfresco/service/api/tags/workspace/SpacesStore/tag1"; DeleteMethod delete = new DeleteMethod(apiurl); try { delete.setDoAuthentication(true); int status = client.executeMethod(delete); if (status != HttpStatus.SC_OK) { System.err.println("Method failed: " + delete.getStatusLine()); } String resultString = delete.getResponseBodyAsString(); System.out.println(resultString); } catch (Exception e) { e.printStackTrace(); } finally { delete.releaseConnection(); }
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 11:14 AM
¡¡Thanks!!
My code is in C# .net. I forgot to tell it
I Have an Exception: Server error 405 . Method not allowed
I have this methods:
My code is in C# .net. I forgot to tell it
I Have an Exception: Server error 405 . Method not allowed
I have this methods:
public string sendDelete(string endPoint) { HttpWebRequest request = CreateWebRequestDelete(endPoint); try { using (var response = (HttpWebResponse)request.GetResponse()) { var responseValue = string.Empty; if (response.StatusCode != HttpStatusCode.OK) { string message = String.Format("DELETE failed. Received HTTP {0}", response.StatusCode); throw new ApplicationException(message); } // grab the response using (var responseStream = response.GetResponseStream()) { using (var reader = new StreamReader(responseStream)) { responseValue = reader.ReadToEnd(); } } return responseValue; } } catch (Exception ex) { return null; } } private HttpWebRequest CreateWebRequestDelete(string endPoint) { var request = (HttpWebRequest)WebRequest.Create(endPoint); request.Method = "DELETE"; request.ContentLength = 0; request.ContentType = "text/xml"; return request; } public string deleteTag(string nameTag) { try { String ticket = admon.getTicketConector(); String url = server + "/alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket; return sendDelete(url); } catch(Exception ex) { throw ex; } }
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 02:09 AM
I have tested your code ,it works fine.Following is test code ,you can test it
public string sendDelete(string endPoint) { HttpWebRequest request = CreateWebRequestDelete(endPoint); try { using (var response = (HttpWebResponse)request.GetResponse()) { var responseValue = string.Empty; if (response.StatusCode != HttpStatusCode.OK) { string message = String.Format("DELETE failed. Received HTTP {0}", response.StatusCode); throw new ApplicationException(message); } // grab the response using (var responseStream = response.GetResponseStream()) { using (var reader = new StreamReader(responseStream)) { responseValue = reader.ReadToEnd(); } } Console.WriteLine(responseValue); return responseValue; } } catch (Exception ex) { return null; } } private HttpWebRequest CreateWebRequestDelete(string endPoint) { var request = (HttpWebRequest)WebRequest.Create(endPoint); request.Method = "DELETE"; request.ContentLength = 0; request.ContentType = "text/xml"; return request; } public string deleteTag(string nameTag) { try { String ticket = getTicketConector(); String url = server + "alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket; return sendDelete(url); } catch (Exception ex) { throw ex; } } public string getTicketConector() { String ticket = null; string URI = server + "alfresco/service/api/login?u=admin&pw=admin"; HttpWebRequest request = WebRequest.Create(URI) as HttpWebRequest; //request.Method = "POST"; //request.ContentType = "application/x-www-form-urlencoded"; try { using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { StreamReader sr = new StreamReader(response.GetResponseStream()); XmlDocument xml = new XmlDocument(); xml.LoadXml(sr.ReadToEnd()); XmlNode root = xml.SelectSingleNode("/ticket"); ticket = root.InnerText; } } catch (Exception e) { return (e.Message + Environment.NewLine + e.StackTrace); } return ticket; }
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 03:39 AM
Thanks, kaynezhang!!!
But I have the same error… I`ve test your code and the server throw the following exception: http code: 405 Method not allowed.
Could it be for the permits of user?. I have admin permission but I am not de administrator or creator of Alfresco repository…
But I have the same error… I`ve test your code and the server throw the following exception: http code: 405 Method not allowed.
Could it be for the permits of user?. I have admin permission but I am not de administrator or creator of Alfresco repository…
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 05:51 AM
Which version of afresco are you using? it might be a bug.
I don't think it is a permission problem,but yuou can give it a try and test it with admin user account
I don't think it is a permission problem,but yuou can give it a try and test it with admin user account
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 04:50 PM
I tried what you tell me and I have not managed to remove a tag.
Thanks for all!
Thanks for all!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2014 09:13 PM
You can download a newer version of alfresco ,and test it to verify if it is a bug of your version
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2015 11:04 AM
Hi!! Could I delete a tag for a node?
I have a 3.4.d version of community Alfresco.
Thanks!!
I have a 3.4.d version of community Alfresco.
Thanks!!
