Any Programmers with Newzbin API experience?
#1
I'm having some issues getting Newzbin support built into Audio-Matic. The API documentation (http://docs.newzbin.com/index.php/Main_Page) is pretty sparse and I was hoping some of you might be able to help.

I can search for reports just fine (using ReportFind url) and I get the expected results, but using pretty much the same code I'm getting a 400 (Bad Request) response no matter what I try when I attempt to download an nzb file (using DirectNZB url) or when I try to get report details (using ReportInfo url).

Here is the VB .Net code that I'm using:

Code:
Public Sub Newzbin_GetNZBfile(ByVal reportID As String)
        Dim strURL, strOutput As String
        Dim NZBresults() As String
        Dim responseHeaders() As String
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim reader As StreamReader

        'API url
        strURL = "http://www.newzbin.com/api/dnzb/"

        Try
            ' Create a request using a URL that can receive a post.
            request = WebRequest.Create(strURL)
            ' Set the Method property of the request to POST.
            request.Method = "POST"
            ' Create POST data and convert it to a byte array.
            Dim postData As String = "username=" & NEWZBIN_USER & "&password=" & NEWZBIN_PASS & "&reportid=" & reportID
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
            ' Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded"
            ' Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length
            ' Get the request stream.
            Dim dataStream As Stream = request.GetRequestStream()
            ' Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length)
            ' Close the Stream object.
            dataStream.Close()
            ' Get the response.
            response = request.GetResponse()
            ' Display the status.
            writeLog("Newzbin STATUS: " & response.StatusCode)
            ' Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            reader = New StreamReader(dataStream)
            ' Read the content.
            strOutput = reader.ReadToEnd()

            responseHeaders = response.Headers.ToString.Split(vbNewLine)

            ' Clean up the streams.
            reader.Close()
            dataStream.Close()
            response.Close()
        Catch ex As Exception
            MsgBox("Error connecting to Newzbin." & vbNewLine & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "Newzbin Connection Problem")
            writeLog("ERROR: fetchDownloads(Newzbin) - Error connecting to Newzbin.  " & ex.Message)
        Finally
            If Not response Is Nothing Then response.Close()
        End Try
    End Sub
Reply
#2
I could be talking crap - specially since I have no .NET experience. But I created a script to fetch data from trakt.tv that was supposed to be a POST method but it never worked if I explicitly set it to post (I used php btw). As soon as I took that line off it started working, maybe you should give that a try if you haven't already...?
Maraschino - github - website
Reply
#3
I don't think that is the issue since the POST method works for the ReportFind url.
Reply
#4
any other suggestions?
Reply
#5
I'm going to try and build a script in php for newzbin and see if I can find anything to help you out.


edit:
Actually I don't have a premium account there, but from the documentation it seems like your ReportID is invalid. Any chance you can post the returned headers (X-DNZB-RCode and X-DNZB-RText) here?
Maraschino - github - website
Reply

Logout Mark Read Team Forum Stats Members Help
Any Programmers with Newzbin API experience?0