[buddypress-trac] [BuddyPress Trac] #8537: BuddyPress API not setting

buddypress-trac noreply at wordpress.org
Mon Jul 26 12:29:52 UTC 2021


#8537: BuddyPress API not setting
--------------------------+-----------------------------
 Reporter:  niftythree    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  9.0.0
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 I’m working on a mobile app to interface with a BuddyPress 9.0.0 website
 via the BP API. The website has some profile fields of the “checkbox”
 type, each with a set of “options” which the user can set to be true or
 false. For example, there is a field of check boxes called “Pets” under
 which the user can select one or more of the specified check boxes such as
 “Dog”, “Cat”, “Cow”, etc.

 I'm trying to update these fields using Postman. The update works fine for
 fields of type “textbox” and “selectbox”, but doesn’t work for the
 “checkbox” type.

 The endpoint is “/buddypress/v1/xprofile/<field_id>/data/<user_id>” (POST
 operation, here the field_id I am using is the id of the parent field)

 A sample of the JSON in the body of my call is

 { “context” : “edit”, “value”: [“Dog”, “Cat”]}

 As mentioned, if I try the same post call with a field of type “textbox”
 or “selectbox”, it works fine, but if I post to a “checkbox” field it just
 clears the existing data and does not set it to the new values.

 Steps to reproduce;
 - Log into WP dashboard as admin
 - Navigate to Users > Profile Fields
 - Add a new field using the "Add New Field" button
 - From the Type category, choose "Checkboxes"
 - Create a few check boxes, and save
 - Use Postman to log into the website
 - Try and set any of the newly created check boxes using the
 “/buddypress/v1/xprofile/<field_id>/data/<user_id>” endpoint (ref. BP API
 documentation for more info).

 Here is a screenshot of Postman when trying to update a "textbox" field
 (successfully updates) https://i.stack.imgur.com/XZgZH.png

 Here is a screenshot of Postman when trying to update a "checkbox" field
 (doesn't update, just clears the existing data instead)
 https://i.stack.imgur.com/zz5Uu.png

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8537>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list