Christian,

Thank you for your reply.

I ran the python script in debug mode to see more information.  It
looks like the authorization https header is getting lost when I
request to upload a diff.  This is not the case if I just request to
open a new review.  Clearly, I have something wrong on the python
side.  I will work on it and post back if I found a resolution.  In
any case, here is the message that I got back through python:

send: b'POST /api/review-requests/26/diffs/ HTTP/1.1\r\nAccept-
Encoding:
  identity\r\nContent-Length: 723\r\nHost: xxx.xxx.x.xxx\r\nContent-
Type:
  application/x-www-form-urlencoded\r\nConnection: close\r\nUser-
Agent:
  --> [empty no username+password] <-- Python-urllib/3.2\r\n\r\
  npath=--+SoMe+BoUnDaRy+++%...[the rest of my post]
reply: 'HTTP/1.1 401 UNAUTHORIZED\r\n'
header: Date header: Server header: Content-Language header: Expires
header:
  Vary header: Cache-Control header: WWW-Authenticate header:
  Content-Length header: Last-Modified header: Connection header:
  Content-Type send: b'POST /api/review-requests/26/diffs/
  HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 723\r
\nHost:
  xxx.xxx.x.xxx\r\nUser-Agent: Python-urllib/3.2\r\nConnection:
  close\r\nContent-Type: application/x-www-form-urlencoded\r
\nAuthorization:
  Basic [with username+password]\r\n\r\npath=
  --+SoMe+BoUnDaRy+++%0AContent-Disposition%...
reply: 'HTTP/1.1 400 BAD REQUEST\r\n

Christian, thanks again.

--Alex


On Nov 20, 6:04 pm, Christian Hammond <chip...@chipx86.com> wrote:
> Hi,
>
> The HTTP 400 you get should have more information about what field had
> problems. Can you show the entire result?
>
> It'd also be good to see the entire payload of data sent to the sever, to
> make sure that you're sending the right thing.
>
> Christian
>
> --
> Christian Hammond - chip...@chipx86.com
> Review Board -http://www.reviewboard.org
> VMware, Inc. -http://www.vmware.com
>
>
>
>
>
>
>
> On Fri, Nov 18, 2011 at 8:13 PM, alexmas <alex...@gmail.com> wrote:
> > I have been struggling to post a diff to ReviewBoard through their
> > API. I've managed to login to the server and create a new post, but
> > I've failed to post correctly the contents of the diff file.
>
> > I'm new to writing this kind of application, but my goal is to have a
> > one step script to:
>
> > diff a file (pre-commit) with the svn repository,
> > add a review request to ReviewBoard and post the diff from the current
> > file,
> > May be later, the script can be part of a svn pre-commit hook.
>
> > My python attempt looks like:
>
> > import urllib.request
> > import urllib.parse
> > import os.path
>
> > ... login to the reviewboard server with
> > urllib.request.HTTPBasicAuthHandler ...
>
> > diff_path = '/path/to/file'
> > diff_name = 'my.diff'
> > diff_path = os.path.join(diff_path, diff_name)
>
> > diff_val = open(diff_path,'r')
>
> > # load the diff into the http data POST request
> > diff_header =                                                    \
> >     '-- SoMe BoUnDaRy   \n'                                     \
> >  +  'Content-Disposition: form-data; name=path; filename='      \
> >  +  '"' + diff_name + '"\n\n'                                   \
> >  +  diff_val.read()  + '\n'                                     \
> >  +  '-- SoMe BoUnDaRy --'
>
> > data ={'path': diff_header, 'basedir': '/path/to/file/in/rep'}
> > print( data['path'] )
> > data = urllib.parse.urlencode(data)
> > data = data.encode('utf-8')
>
> > opener.open(                                      \
> >    'http://xxx.xxx.x.xxx/api/review-requests/26/diffs/', data)
> > With this code I get a BAD REQUEST(400) error, specifically: "One or
> > more fields had errors" (105).
>
> > I'm aware that there are some libraries out there that can talk with
> > the ReviewBoard's API. I'd rather not have to distribute to the other
> > developers another python library.
>
> > I'm also aware that post-review exists.  I don't think that post-
> > review can upload a diff of a files with versions committed to
> > different paths in the repository.  I have reason for this.  We have
> > just begun implementing code reviews and we've inherit a lot of old
> > code that needs to be reviewed from this point forward.  To keep track
> > of the files that have been reviewed and their reviewed content, I've
> > created a peer-reviewed branch.  Now, each time a file is reviewed
> > it's copied to this branch.  If a file is modified, then it is diffed
> > against the branch and the new version moved with svn.  At some point
> > we'll get to 100% review coverage, and the branch will go away.
>
> > --
> > Want to help the Review Board project? Donate today at
> >http://www.reviewboard.org/donate/
> > Happy user? Let us know athttp://www.reviewboard.org/users/
> > -~----------~----~----~----~------~----~------~--~---
> > To unsubscribe from this group, send email to
> > reviewboard+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/reviewboard?hl=en

-- 
Want to help the Review Board project? Donate today at 
http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to 
reviewboard+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/reviewboard?hl=en

Reply via email to