Looks like we have an error in the docs. It should be
reviewboard.webapi.base.

Were you making a GET or a POST request to the URL? Can you show me the
payload information?

Can you add logging to your handler and find out how far a request gets? I
imagine it's failing in the review_request_resource.get_object() call,
because it's not expecting to be called from outside a
/api/review-requests/<id>/ tree without being passed a keyword argument for
the review request ID. You might want to either query the database yourself
or make sure you're passing the ID as a keyword argument (it's possible
this isn't enough, but give it a try).

Christian

On Mon, Jul 9, 2018 at 9:25 AM <amull...@ucsd.edu> wrote:

> I'm trying to get the sample from
> https://www.reviewboard.org/docs/manual/3.0/extending/extensions/webapi/
>  to work on ReviewBoard 3.0.7. I did exactly what the sample code did, but
> the import path of WebAPIResource was
> from reviewboard.api.base instead of reviewboard.api.resources. Is there
> anything that might be wrong?
>
>
> class SampleExtensionResource(WebAPIResource):
>     logging.info("asdf")
>     """Resource for creating reviews"""
>     name = 'sample_extension_review'
>     uri_name = 'review'
>     allowed_methods = ('POST',)
>
>     def has_access_permissions(self, request, *args, **kwargs):
>         return review_request.is_accessible_by(request.user)
>
>     @webapi_check_local_site
>     @webapi_login_required
>     @webapi_response_errors(DOES_NOT_EXIST)
>     @webapi_request_fields(
>         required={
>             'review_request_id': {
>                 'type': int,
>                 'description': 'The ID of the review request',
>             },
>         },
>     )
>     def create(self, request, review_request_id, *args, **kwargs):
>         try:
>             review_request = review_request_resource.get_object(
>                 request, review_request_id, *args, **kwargs)
>         except ObjectDoesNotExist:
>             return DOES_NOT_EXIST
>
>         new_review = Review.objects.create(
>             review_request=review_request,
>             user=request.user,
>             body_top='Sample review body')
>
>         #TODO: write to draft with necessary information and then publish
>         #get draft
>
>         #update draft with proper fields
>
>
>
>         #publishs draft
>         new_review.publish(user=request.user)
>
>         return 201, {
>             self.item_result_key: new_review
>         }
>
> sample_review_resource = SampleExtensionResource()
>
>
> class SampleExtension(Extension):
>     def initialize(self):
>         #js_extensions = [StateJSExtension]
>         #js_bundles = {
>         #       'default': {
>         #               'source_filenames': [
>         #                       'js/state.js'
>         #               ]
>         #       }
>         #}
>
>         ApprovalHook(self)
>         resources = [sample_review_resource]
>         #if get_review_request_fieldset(fieldset_id) == None:
>         #  register_review_request_fieldset(PRMTFieldSet)
>         ReviewRequestFieldSetsHook(self, [PRMTFieldSet])
>
>
>
> I went on Postman and made an API call to
> http://localhost/api/extensions/sample_extension.extension.SampleExtension/review/
> , and it says the object does not exist.
>
> --
> 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 reviewboard+unsubscr...@googlegroups.com.
> 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 reviewboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to