Hi Christian Hammond,
   We are trying to upload a diff to a draft review request using http api 
request ,however we are unable to upload the diff file.
Actually we don't know the correct url to upload the diff file and also 
need to know which all data fields are required for uploading the diff file.
Following is the code  we are using and the error message:
We tried with both put and post method:
****************
import requests
import json
from requests.auth import HTTPBasicAuth

username="username"
password="password"
API_ENDPOINT_2 ="https://reviewserver/api/review-requests/135/draft/diffs/";
payload = {"basedir":"/","path":"C:\\review\\diff1.diff"} 
r2 = requests.post(url= API_ENDPOINT_2,auth=HTTPBasicAuth(username, 
password),form-data,name="C:\\review\\",filename="diff1.diff")
print(r2.text)
****************
Error message while using put:

<!DOCTYPE html>

<html>
 <head>
  <title>500 - Internal Server Error | Review Board</title>
 </head>
 <body>
  <h1>Something broke! (Error 500)</h1>
  <p>
   It appears something broke when you tried to go to here. This is either
   a bug in Review Board or a server configuration error. Please report
   this to your administrator.
  </p>
 </body>
</title>

*******************************
Error message while using post:
{"fields": {"path": ["This field is required"]}, "stat": "fail", "err": 
{"msg": "One or more fields had errors", "code": 105}}

********************************
Following are the info of the created review request:

{"stat": "ok", "draft": {"commit_id": null, "extra_data": {}, 
"last_updated": "2019-02-22T08:13:23Z", "description": "description06", 
"target_people": [], "changedescription": "", "depends_on": [], 
"description_text_type": "plain", "target_groups": [], 
"testing_done_text_type": "plain", "links": {"self": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/";, "method": 
"GET"}, "draft_diffs": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/diffs/";, "method": 
"GET"}, "update": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/";, "method": 
"PUT"}, "draft_screenshots": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/screenshots/";, 
"method": "GET"}, "draft_file_attachments": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/file-attachments/";, 
"method": "GET"}, "submitter": {"href": 
"https://reviewserver.com/api/users/Sbiroot/";, "method": "GET", "title": 
"Sbiroot"}, "review_request": {"href": 
"https://reviewserver.com/api/review-requests/135/";, "method": "GET", 
"title": "summary06"}, "delete": {"href": 
"https://reviewserver.com/api/review-requests/135/draft/";, "method": 
"DELETE"}}, "summary": "summary06", "testing_done": "", "branch": "", 
"text_type": null, "id": 132, "bugs_closed": [], 
"changedescription_text_type": "plain", "public": false}}

On Wednesday, February 20, 2019 at 10:17:15 AM UTC+5:30, Adithya R wrote:
>
> Review Board Version:*3.0.7  *
>
> On Wed, Feb 20, 2019 at 10:14 AM Adithya R <
> [email protected]> wrote:
>
>> Using RBTool 1.0.1
>>
>> On Wed, Feb 20, 2019 at 3:38 AM Christian Hammond <
>> [email protected]> wrote:
>>
>>> What version of Review Board are you using?
>>>
>>> Christian
>>>
>>> On Mon, Feb 18, 2019 at 9:36 PM Adithya R <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>  
>>>> The diff file was generated using  pysvn from SVN repository.
>>>> I have attached the diff file  along with this mail.
>>>>
>>>>
>>>> On Sat, Feb 16, 2019 at 3:54 AM Christian Hammond <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> It's upset that the diff is "empty." That doesn't necessarily mean 
>>>>> there's no diff content, but it may not have found anything that parsed 
>>>>> as 
>>>>> a valid diff containing changed files.
>>>>>
>>>>> Is it possible to share the diff with us?
>>>>>
>>>>> How was the diff generated? What type of repository is this for?
>>>>>
>>>>> Christian
>>>>>
>>>>> On Wed, Feb 13, 2019 at 9:15 AM <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I need some help to resolve this issue 
>>>>>>
>>>>>> I am trying to upload a diff file using python to a newly created  
>>>>>> review request using RBTools-1.0.1.
>>>>>> The review request gets created in the review board.The diff file 
>>>>>> upload is fails.
>>>>>> Following is the code,however I am getting the error as following:
>>>>>>
>>>>>> **********************************
>>>>>> from rbtools.api.client import RBClient
>>>>>>
>>>>>>
>>>>>> client = RBClient('https://reviewserver',
>>>>>>                   username='username',
>>>>>>                   password='password')
>>>>>> root = client.get_root()
>>>>>>
>>>>>> repos = root.get_repositories()
>>>>>>
>>>>>> if repos.num_items < 1:
>>>>>>     raise Exception('No valid repositories.')
>>>>>>
>>>>>> repository = repos[0].id
>>>>>> print(repository)
>>>>>>
>>>>>> review_request = 
>>>>>> root.get_review_requests().create(repository=repository)
>>>>>>
>>>>>> f = open("C:\\Users\\User\\Desktop\\Python\\f4.diff", mode="r")
>>>>>> diff_contents = f.read()
>>>>>> print(f)
>>>>>> f.close()
>>>>>>
>>>>>> review_request.get_diffs().upload_diff(diff_contents,base_dir= '/')
>>>>>> ***********************************
>>>>>>
>>>>>> Error Message:
>>>>>>
>>>>>>
>>>>>> C:\Users\User\Desktop\Python>python reviewboard_Feb12.py
>>>>>> 1
>>>>>> <_io.TextIOWrapper name='C:\\Users\\User\\Desktop\\Python\\f4.diff' 
>>>>>> mode='r' encoding='cp1252'>
>>>>>> Traceback (most recent call last):
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\request.py",
>>>>>>  
>>>>>> line 601, in make_request
>>>>>>     request.url, body, headers, request.method))
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\cache.py",
>>>>>>  
>>>>>> line 209, in make_request
>>>>>>     return self.urlopen(request)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\urllib\request.py",
>>>>>>  
>>>>>> line 222, in urlopen
>>>>>>     return opener.open(url, data, timeout)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\urllib\request.py",
>>>>>>  
>>>>>> line 531, in open
>>>>>>     response = meth(req, response)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\request.py",
>>>>>>  
>>>>>> line 239, in http_response
>>>>>>     response.info())
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\urllib\request.py",
>>>>>>  
>>>>>> line 569, in error
>>>>>>     return self._call_chain(*args)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\urllib\request.py",
>>>>>>  
>>>>>> line 503, in _call_chain
>>>>>>     result = func(*args)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\urllib\request.py",
>>>>>>  
>>>>>> line 649, in http_error_default
>>>>>>     raise HTTPError(req.full_url, code, msg, hdrs, fp)
>>>>>> urllib.error.HTTPError: HTTP Error 400: BAD REQUEST
>>>>>>
>>>>>> During handling of the above exception, another exception occurred:
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>>   File "reviewboard_Feb12.py", line 24, in <module>
>>>>>>     review_request.get_diffs().upload_diff(diff_contents,base_dir 
>>>>>> ='None')
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\decorators.py",
>>>>>>  
>>>>>> line 27, in request_method
>>>>>>     *args, **kwargs)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\transport\sync.py",
>>>>>>  
>>>>>> line 77, in execute_request_method
>>>>>>     return self._execute_request(request)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\transport\sync.py",
>>>>>>  
>>>>>> line 86, in _execute_request
>>>>>>     rsp = self.server.make_request(request)
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\request.py",
>>>>>>  
>>>>>> line 603, in make_request
>>>>>>     self.process_error(e.code, e.read())
>>>>>>   File 
>>>>>> "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\rbtools\api\request.py",
>>>>>>  
>>>>>> line 577, in process_error
>>>>>>     rsp['err']['msg'])
>>>>>> rbtools.api.errors.BadRequestError: The specified diff file is empty. 
>>>>>> (HTTP 400, API Error 219)
>>>>>>
>>>>>> ***********************************
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Supercharge your Review Board with Power Pack: 
>>>>>> https://www.reviewboard.org/powerpack/
>>>>>> Want us to host Review Board for you? Check out RBCommons: 
>>>>>> https://rbcommons.com/
>>>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>>>> --- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "Review Board Community" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Christian Hammond
>>>>> President/CEO of Beanbag <https://www.beanbaginc.com/>
>>>>> Makers of Review Board <https://www.reviewboard.org/>
>>>>>
>>>>> -- 
>>>>> Supercharge your Review Board with Power Pack: 
>>>>> https://www.reviewboard.org/powerpack/
>>>>> Want us to host Review Board for you? Check out RBCommons: 
>>>>> https://rbcommons.com/
>>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>>> --- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "Review Board Community" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>> -- 
>>>>
>>>> Thanks & Regards*,*
>>>>
>>>> *Adithya R*
>>>> ​
>>>> ​
>>>> ​
>>>> ​​CloudPlus Information Technologies Pvt Ltd
>>>> II Floor, Ashtamudi Tower, Technopark | Kerala | India​
>>>>
>>>> ​​
>>>> Phone: +91 9495841256
>>>> ​ | [email protected] <[email protected]>
>>>> ​
>>>> ​
>>>> ​
>>>> ​www.cloudplusinfotech.com | Cloud, Big Data Analytics & Devops 
>>>> Services
>>>>
>>>> -- 
>>>> Supercharge your Review Board with Power Pack: 
>>>> https://www.reviewboard.org/powerpack/
>>>> Want us to host Review Board for you? Check out RBCommons: 
>>>> https://rbcommons.com/
>>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Review Board Community" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>> -- 
>>> Christian Hammond
>>> President/CEO of Beanbag <https://www.beanbaginc.com/>
>>> Makers of Review Board <https://www.reviewboard.org/>
>>>
>>> -- 
>>> Supercharge your Review Board with Power Pack: 
>>> https://www.reviewboard.org/powerpack/
>>> Want us to host Review Board for you? Check out RBCommons: 
>>> https://rbcommons.com/
>>> Happy user? Let us know! https://www.reviewboard.org/users/
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Review Board Community" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> -- 
>>
>> Thanks & Regards*,*
>>
>> *Adithya R*
>> ​
>> ​
>> ​
>> ​​CloudPlus Information Technologies Pvt Ltd
>> II Floor, Ashtamudi Tower, Technopark | Kerala | India​
>>
>> ​​
>> Phone: +91 9495841256
>> ​ | [email protected] <[email protected]>
>> ​
>> ​
>> ​
>> ​www.cloudplusinfotech.com | Cloud, Big Data Analytics & Devops Services
>>
>>
>
> -- 
>
> Thanks & Regards*,*
>
> *Adithya R*
> ​
> ​
> ​
> ​​CloudPlus Information Technologies Pvt Ltd
> II Floor, Ashtamudi Tower, Technopark | Kerala | India​
>
> ​​
> Phone: +91 9495841256
> ​ | [email protected] <[email protected]>
> ​
> ​
> ​
> ​www.cloudplusinfotech.com | Cloud, Big Data Analytics & Devops Services
>
>

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to