How to update draft's beanbag_notefield_notes?

54 views
Skip to first unread message

Hema

unread,
Mar 31, 2020, 2:41:02 AM3/31/20
to Review Board Community
We use ReviewBoard 3.0.3 and RBTools 1.0.2. We try to update review request draft's beanbag_notefield_notes like below.

draft = draft.update(extra_data:json-patch={'op':'replace', 'path':'beanbag_notefield_notes','value':'hsagds'})

But it doesn't work. Could you please point the mistake, here?

Thanks,
Hemapriya.

David Trowbridge

unread,
Mar 31, 2020, 1:46:22 PM3/31/20
to reviewboard
It would be helpful if you included any error messages, but I suspect it's just a Python syntax problem--argument names can't contain a ":" character.

We should be able to get around this using a kwargs dict:

kwargs = {
    'extra_data:json-patch': {
        'op': 'replace',
        'path': 'beanbag_notefield_notes',
        'value': 'hsagds',
    },
}

draft.update(**kwargs)


David


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/1405414c-2d37-4b71-a653-9828873ce591%40googlegroups.com.

Hemapriya

unread,
Apr 1, 2020, 12:43:03 AM4/1/20
to revie...@googlegroups.com
Thanks for the reply. But we still face problem updating this field. Please find it below.

>>> Making HTTP PUT request to https://reviewboard.com/api/review-requests/29254/draft/
>>> Got API Error 105 (HTTP code 400): One or more fields had errors
>>> Error data: {u'fields': {u'extra_data': [u'Could not parse JSON data: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)']}, u'stat': u'fail', u'err': {u'msg': u'One or more fields had errors', u'code': 105}}
...
  File "/usr/hemapriya/p4/rbtools/../rbtools/commands/post.py", line 817, in post_request
    draft = draft.update(**kwargs)
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/resource.py", line 181, in <lambda>
    meth(resource, **kwargs)))
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/decorators.py", line 27, in request_method
    *args, **kwargs)
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/transport/sync.py", line 77, in execute_request_method
    return self._execute_request(request)
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/transport/sync.py", line 86, in _execute_request
    rsp = self.server.make_request(request)
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/request.py", line 687, in make_request
    self.process_error(e.code, e.read())
  File "/usr/hemapriya/p4/rbtools/../rbtools/api/request.py", line 661, in process_error
    rsp['err']['msg'])
rbtools.api.errors.BadRequestError:     extra_data: Could not parse JSON data: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

My code looks like:
kwargs = {"extra_data:json-patch": {"op":"replace", "path":"beanbag_notefield_notes", "value":"hsagds"}}
draft = draft.update(**kwargs)

Could you please help?

Thanks,
Hemapriya.

You received this message because you are subscribed to a topic in the Google Groups "Review Board Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/rIRitlsdNfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reviewboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/CAFS3VNUnv5GWL7VGFwmYCLD3VGdxDqSu4aGVeV4p3%3D5%3Dy6o7SA%40mail.gmail.com.

David Trowbridge

unread,
Apr 2, 2020, 1:21:56 PM4/2/20
to reviewboard
After looking a little deeper, it looks like the json-patch data needs to be in an array, but also serialized. Try this:

kwargs = {
    'extra_data:json-patch': json.dumps(
        [
            {
                'op': 'replace',
                'path': 'beanbag_notefield_notes',
                'value': 'hsagds',
            },
        ]
    ),
}

Hema

unread,
Apr 3, 2020, 4:23:07 AM4/3/20
to Review Board Community
Still no luck. Got the following error for the suggested code.
CRITICAL:     extra_data: Failed to patch JSON data: Syntax error in path "beanbag_notefield_notes" for patch entry 0: Paths must either be empty or start with a "/"

Hence added "/" in path. But got the following error.
CRITICAL:     extra_data: Failed to patch JSON data: Cannot write to path "/beanbag_notefield_notes" for patch entry 0

What should be the path to update 'beanbag_notefield_notes'?

Regards,
Hemapriya.
To unsubscribe from this group and stop receiving emails from it, send an email to revie...@googlegroups.com.

--
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 a topic in the Google Groups "Review Board Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reviewboard/rIRitlsdNfU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to revie...@googlegroups.com.

--
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 revie...@googlegroups.com.

Hema

unread,
Apr 13, 2020, 1:49:43 AM4/13/20
to Review Board Community
Can I get help on this, please?

Regards,
Hemapriya.

Christian Hammond

unread,
Apr 14, 2020, 9:39:32 PM4/14/20
to revie...@googlegroups.com
Hi Hema,

Sorry, we've been pretty busy on our paid support tracker lately, especially with the pandemic situation. (Small plug: We can help more closely and quickly with in-house customizations with a support contract, which might be useful if you're doing a lot of custom stuff.)

I looked into this, and this key is protected when this extension is enabled. That means you can't patch it. If you disable the extension temporarily, you should be able to modify it.

Patching, though, is probably the wrong approach. I think you want to just set the field value, which is different. Set:

    extra_data.beanbag_notefield_notes_text_type=markdown
    extra_data.beanbag_notefield_notes=<your new text here>

If you want plain text, use 'plain' instead of 'markdown'.

To see a real-world example, open your browser's development tools, view the Network tab, reload the page, and set the Note to Reviewers field. You'll see the data that gets sent in.

Christian

To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/28a0cae4-4329-4858-a6cd-c1eed1a2e141%40googlegroups.com.


--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

Hema

unread,
Apr 15, 2020, 12:09:57 AM4/15/20
to Review Board Community
Thanks for the solution. It worked.

Regards,
Hemapriya.
Reply all
Reply to author
Forward
0 new messages