Unhelpful 500 response in Confluence Rest API for uploading attachment

1,446 views
Skip to first unread message

Stephen Rollins

unread,
Jun 26, 2014, 7:11:40 PM6/26/14
to atlassian-...@googlegroups.com
I am trying to use the Confluence REST API to upload an attachment and I'm getting this response:

{"statusCode":500,"message":"javax.ws.rs.WebApplicationException: null"}

I've tried to simplify the moving parts as much as possible. While this error is happening in my add-on, it is also happening if I try a simple curl request:

curl -vk -X POST http://(confluence url):1990/confluence/rest/api/content/(page id)/child/attachments -H "X-Atlassian-Token: nocheck" -H "Authorization: JWT (token)" -F file=@image.png

I've done my best to follow the Confluence REST API Documentation in this matter; however, the documentation is inconsistent, particularly with regard to the url I should be hitting. I have also tried to POST to /confluence/rest/api/content/(page id)/attachments, and that results in an xml 404 response:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: http://(confluence url):1990/confluence/rest/api/content/(page id)/attachments</message></status>

I am developing for Confluence 5.5-OD-23-004.

Here is a brief stack trace that gets logged during the 500 error:

2014-06-26 17:03:10,401 ERROR [http-1990-1] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error : 
 -- url: /confluence/rest/api/content/(page id)/child/attachments | userName: addon_(addon-key)
javax.ws.rs.WebApplicationException
at com.sun.jersey.server.impl.uri.rules.TerminatingRule.accept(TerminatingRule.java:66)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:178)
...

What am I doing wrong?

Stephen Rollins

unread,
Jul 1, 2014, 11:44:19 AM7/1/14
to atlassian-...@googlegroups.com
It turns out this error was a matter of misspelling the URL. It should have been /child/attachment, not /child/attachments.


--
You received this message because you are subscribed to a topic in the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/atlassian-connect-dev/wb2J1OD7QN0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages