Page 1 of 1

API returns HTTP 406 but still continues?

Posted: April 22nd, 2010, 4:32 pm
by Hmail
I'm getting some pretty weird behavior from the API, and I obviously want to talk properly to SABnzbd from my application. I'm sending this data to the api:

Code: Select all

POST /sabnzbd/api?mode=addfile&name=MovieX&cat=anime&apikey=APIKEY HTTP/1.1
Content-Type: multipart/form-data; boundary=8ccafbe245b1ffd
Accept-Encoding: *
Cookie: session_id=18ac5d3efc8874e10940ef97c991a6fc0f879e54
Content-Length: 1856744
Connection: Keep-Alive
Accept-Language: en-US,*
User-Agent: Mozilla/5.0
Host: tiffany:7777

--8ccafbe245b1ffd
Content-Disposition: form-data; name="name"; filename="MovieX"
Content-Type: text/plain

<?xml version="1.0" encoding="iso-8859-1" ?>

// Content stripped from NZB

</nzb>

--8ccafbe245b1ffd--

The API returns a HTML file with error code 406, and I found this in the body:

Code: Select all

        <h2>406 Not Acceptable</h2>
        <p>identity, gzip</p>
I honestly don't know why this is, and I was expecting a 200 OK response. The following header does this, but I don't see much difference:

Code: Select all

POST /sabnzbd/api?mode=addfile&name=MovieX&cat=anime&apikey=APIKEY
HTTP/1.1
Content-Type: multipart/form-data; boundary=8ccb08376f63782
Host: tiffany:7777
Content-Length: 390848
Expect: 100-continue

HTTP/1.1 100
Content-Length: 0
Content-Type: text/plain

--8ccb08376f63782
Content-Disposition: form-data; name="name"; filename="MovieX"
Content-Type: text/plain

<?xml version="1.0" encoding="utf-8" ?>
...
</nzb>


--8ccb08376f63782--

Can someone explain why I get this 406 header, and how to prevent this? Note: SABnzbd still starts the download, like nothing was wrong, but I just want to do it the right way. I got nothing from SABnzbd logs, this just says pretty much the same, that it returned the 406 header.

Also note that the reason these two headers from my application are different is that the first is coded using QT (c++) and the other C#.NET. So different platforms, and I can't get QT to behave exactly like C#.NET.

Re: API returns HTTP 406 but still continues?

Posted: April 22nd, 2010, 6:10 pm
by switch
Looks like an Accept Encoding of "*" might not be supported by CherryPy (our webserver).
http://www.freesoft.org/CIE/RFC/2068/158.htm

If you do not provide an accept encoding at all (as on the second request) it is assumed you can accept all encodings. However * does not seem to be accepted as all encodings.

Re: API returns HTTP 406 but still continues?

Posted: April 23rd, 2010, 8:40 am
by Hmail
Is it true it only accepts "Accept-Encoding: gzip" or no Accept-Encoding? Unfortunately, it looks like I can't unset the Accept-Encoding-header, so I either have to live with this, or find a way to gunzip the content. I would love to receive a text/plain response, but I can't request that with the Accept-Encoding header. It keeps returning the 406 error.