406 not acceptable on POST /issues.xml

Added by Check Mate about 8 years ago

Hi Forum! This is my first post here and i only recently started working with Redmine.

I have a (hopefully small) problem with my Redmine 1.4-stable installation on ubuntu.

When i am making a POST to /uploads.xml with the following content:

POST /issues.xml

<issue>
<subject>Example</subject>
<project_id>1</project_id>
<priority_id>1</priority_id>
</issue>

I get a 406 "not acceptable". I played around with the fields and made sure that i am authenticated as admin and that the POST is well formed. I also checked if the project_id and priority_id exist, they do. Setting the Logger-Level to DEBUG did not really shed light onto the issue. Some SQL which seems correct and working.

As i am new to Redmine i am wondering what i might have done wrong. The installation, the POST, or what?

FYI: I am also able to Create Issues via the website and java-rest-api. I am asking for this because i can't find a possibility to use the java-rest-api to connect issues with attachments i have uploaded. So i am trying to understand the way i can do it with XML. Any help on this or help on alternative ways to attach files to issues would also be very appreciated.

--checkMateZ

Replies (7)

RE: 406 not acceptable on POST /issues.xml - Added by Etienne Massip about 8 years ago

How do you issue the request?

RE: 406 not acceptable on POST /issues.xml - Added by Check Mate about 8 years ago

Etienne Massip wrote:

How do you issue the request?

Currently i have no access to my computer at work, so i can't post a code snippet. But i have copied the code of a page (google for "using-java-post-block-xml-web" it's the post on DZone from 03.03.2009)*. What i do is in Java(jdk1.6) i create a String with the content as value and submit it via an URLconnection. At some point i also add the credentials, which should be ok as i don't get a 401/403.

*couldn't post the link as my post is marked as spam if i do

RE: 406 not acceptable on POST /issues.xml - Added by Check Mate about 8 years ago

Etienne Massip wrote:

How do you issue the request?

This is the way i issue the request. See attached file.

FaultExample.java Magnifier (2.42 KB)

RE: 406 not acceptable on POST /issues.xml - Added by Check Mate about 8 years ago

Check Mate wrote:

This is the way i issue the request.

And this is the corresponding production log entry. See attached file.

production_log.txt Magnifier - Production log (2.29 KB)

RE: 406 not acceptable on POST /issues.xml - Added by Etienne Massip about 8 years ago

You're mixing creation of issue and attachment upload since you try to make a POST to /upload.xml with some issue request body.

Please read Rest_api#Attaching-files and:
  1. upload the attachment with a POST /uploads.xml
  2. create the issue with a POST /issues.xml or update it with a PUT /issues.xml and specify the token you received in response to the previous upload request

FYI, there is also a more specific HttpURLConnection, it could be more enjoyable to use.

RE: 406 not acceptable on POST /issues.xml - Added by Check Mate about 8 years ago

Hi Etienne,

thank you for you answer. I just reinstalled redmine step by step to make sure it is allright and changed the Url to host/issues.xml as proposed by you. Now adding a issue in this way works!

I will now test uploading an issue with a token and report back within the day.

RE: 406 not acceptable on POST /issues.xml - Added by Check Mate about 8 years ago

It's working quite wonderful. :)

A BIG THANK YOU from me and my colleagues (which are testing "on the road") as well. The outcome of this little thread will make their life much easier.

(1-7/7)