Title: API POST/PATCH doesn&#8217;t update (or create) the record
Last modified: August 7, 2024

---

# API POST/PATCH doesn’t update (or create) the record

 *  Resolved [mcdouchedy](https://wordpress.org/support/users/mcdouchedy/)
 * (@mcdouchedy)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/)
 * All is working well when using the API except when trying to create or change
   a record in the DB: the fields in the body of my request are not updated. It’s
   to say, the custom fields I created; some fields like ‘last modified’ are updated.
 * Any clue? I tried a lot, but without success. ( even the delete of a record works,
   so I guess I have enough privileges to do updates or create new records )
 * **Postman:** simplest call (POST or PATCH) to change a field ‘make’ of record
   4 (which works very well in the admin console)
 * PATCH /wp-json/participants-database/v1/record/update/4
 * HTTP/1.1
   Host: [http://www.paragarage.be](http://www.paragarage.be)Content-Type:
   application/jsonAuthorization: Basic TWNEb3Vja***************************************
   GRVN08gMFVCNg==Cookie: PHPSESSID=rpcc32b9q08g0pe44nbn2ih43kContent-Length: 23
 * {
   “make”: “Ozone”}
 * **Log: Particpants DB** ( always returns the unmodified value, the ‘data_updated’
   changed )
 * [08/07/24 2:19pm UTC] PDb_submission\main_query\base_query::execute_query storing
   record: UPDATE wp_participants_database SET `date_updated` = “2024-08-07 14:19:
   34”, `make` = ‘Niviu’, `approved` = ‘yes’, `last_update_user` = ‘McDouchedy’ 
   WHERE id = 4 [08/07/24 2:19pm UTC]
 * PDb_Participant_Cache::reload_cache: Refreshing Participants Database cache for
   cache group 0
 * [08/07/24 2:20pm UTC] PDb_List_Admin::initialize list query: SELECT * FROM wp_participants_database
   p ORDER BY p.date_updated desc LIMIT 0,200
 * **THANKS FOR THE HELP!**

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/#post-17940370)
 * First, the API will only respond to POST or GET requests.
 * You don’t mention what the response code was, it should be a 200 if successful.
   If a POST request is not successful, you probably are not authorizing the request
   properly. This is [explained in the documentation.](https://xnau.com/work/wordpress-plugins/participants-database/participants-database-documentation/participants-database-rest-api/)
 * I just tested this operation and it is working.
 *  Thread Starter [mcdouchedy](https://wordpress.org/support/users/mcdouchedy/)
 * (@mcdouchedy)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/#post-17944590)
 * OK, I stick to POST and GET from now on. The response was/is still 200 for a 
   POST ( to add or update a record ). When I authorize the request for a delete,
   it’s working: the empty record created with my previous add is deleted.
 * Here’s the output of another tool:
 * POST:
 *     ```wp-block-code
       {    "uri": "https://www.paragarage.be/wp-json/participants-database/v1/record/add",    "method": "POST",    "headers": {        "accept": "*/*",        "Accept-Encoding": "gzip, deflate, br",        "Connection": "keep-alive",        "Content-Type": "application/json"    },    "authentication": {        "username": "McDouchedy",        "password": "*sanitized*",        "type": "Basic"    },    "body": {        "make": "Ozone",        "model": "Niviuk",        "serial": "1234"    }}
       ```
   
 * RESPONSE:
 *     ```wp-block-code
       {    "statusCode": 200,    "headers": {        "Server": "nginx",        "Date": "Sat, 10 Aug 2024 05:53:09 GMT",        "Transfer-Encoding": "chunked",        "Connection": "keep-alive",        "Pragma": "no-cache",        "X-Robots-Tag": "noindex",        "Link": "<https://www.paragarage.be/wp-json/>; rel=\"https://api.w.org/\"",        "X-Content-Type-Options": "nosniff",        "Access-Control-Expose-Headers": "X-WP-Total, X-WP-TotalPages, Link",        "Access-Control-Allow-Headers": "Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type",        "Cache-Control": "no-store, must-revalidate, no-cache, max-age=0, private",        "Set-Cookie": "PHPSESSID=q6dam9rn4jj4lk1iv9p9icss2u; path=/",        "Content-Type": "application/json; charset=utf-8",        "Allow": "POST,PUT,PATCH",        "Expires": "Wed, 11 Jan 1984 05:00:00 GMT",        "Content-Length": "15"    },    "body": {        "record_id": 7    }}
       ```
   
 * EMPTY record created with id 7 ( not sure if you see the image ):
 * make model serial report validity Administrative Info Approved Record Info Last
   Updater Record ID read only Private ID Date Recorded
 * ![](https://wordpress.org/392a819c-36ba-4584-afa2-d3dc675c271a)
 * Delete the record:
 *     ```wp-block-code
       {    "uri": "https://www.paragarage.be/wp-json/participants-database/v1/record/delete/7",    "method": "POST",    "headers": {        "accept": "*/*",        "Accept-Encoding": "gzip, deflate, br",        "Connection": "keep-alive",        "Content-Type": "application/json"    },    "authentication": {        "username": "McDouchedy",        "password": "*sanitized*",        "type": "Basic"    }}
       ```
   
 * Answer:
 *     ```wp-block-code
       {    "statusCode": 200,    "headers": {        "Server": "nginx",        "Date": "Sat, 10 Aug 2024 05:58:35 GMT",        "Transfer-Encoding": "chunked",        "Connection": "keep-alive",        "Pragma": "no-cache",        "X-Robots-Tag": "noindex",        "Link": "<https://www.paragarage.be/wp-json/>; rel=\"https://api.w.org/\"",        "X-Content-Type-Options": "nosniff",        "Access-Control-Expose-Headers": "X-WP-Total, X-WP-TotalPages, Link",        "Access-Control-Allow-Headers": "Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type",        "Cache-Control": "no-store, must-revalidate, no-cache, max-age=0, private",        "Set-Cookie": "PHPSESSID=lvjj8o55un3s46rimkese84o30; path=/",        "Content-Type": "application/json; charset=utf-8",        "Allow": "POST,PUT,PATCH",        "Expires": "Wed, 11 Jan 1984 05:00:00 GMT",        "Content-Length": "4"    },    "body": true}
       ```
   
 * The result is that the record is deleted.
 * That’s why I think the authentication is ok. I only have one user on this setup
   and it’s also the admin. The possibility to make anonymous request is not enabled.
 * I have the impression that the fieldnames in my request doesn’t match the fields
   in the record, and that’s why the record is created and all the fields are empty
   but I took the output of a GET record and pasted the body into a POST. Is there
   something with the encoding that I should check? I already emptied the DB and
   started over again with a new one. I don’t know anymore what I should check or
   test… Any hints are welcome 🙂
    -  This reply was modified 1 year, 9 months ago by [mcdouchedy](https://wordpress.org/support/users/mcdouchedy/).
      Reason: Image not visible
 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/#post-17947942)
 * Yes, the authentication is OK.
 * Looking at the header, it looks like the content type should be set to “multipart/
   form-data”, you’re using “application/javascript” I don’t know if that is the
   problem, but that’s the only difference from what is working in my tests here.
 *  Thread Starter [mcdouchedy](https://wordpress.org/support/users/mcdouchedy/)
 * (@mcdouchedy)
 * [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/#post-17948396)
 * Thanks a lot Mr Barker, this was indeed the problem. The syntax of the body is
   a bit more complex than with JSON, but it does the job and that’s the most important.
 *     ```wp-block-code
       {    "uri": "https://www.paragarage.be/wp-json/participants-database/v1/record/update/11",    "method": "POST",    "headers": {        "content-type": "multipart/form-data; boundary=separator",        "accept": "*/*",        "accept-encoding": "gzip, deflate, br",        "connection": "keep-alive"    },    "authentication": {        "username": "McDouchedy",        "password": "*sanitized*",        "type": "Basic"    },    "body": "--separator\nContent-Disposition: form-data; name=\"make\"\n\nrebelie\n--separator--"}
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘API POST/PATCH doesn’t update (or create) the record’ is closed to new
replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [mcdouchedy](https://wordpress.org/support/users/mcdouchedy/)
 * Last activity: [1 year, 9 months ago](https://wordpress.org/support/topic/api-post-patch-doesnt-update-or-create-the-record/#post-17948396)
 * Status: resolved