Using REST API to update an entry

By: Mike Harding | Asked: 05/24/2024
ForumsCategory: Code HelpUsing REST API to update an entry
Mike Harding asked 7 months ago
I have a large FF form that has multiple entries. In order to create some value add, I'm using the outbound API to call a PHP script on another a remote server and process some info there (not a wordpress instance.) The result of this processing needs to be reflected in the entry that was created on the wordpress instance with FF. I'm not an experienced REST API person, but in browsing answers in the forum and the documentation, this seems to be the correct route to use. When looking at the FF REST API documentation, it's pretty good until one scrolls to entries, update a single entry. The sample code seems not to be available for that use case. https://strategy11.github.io/formidable-forms-rest-api-docs/?php#update-a-single-entry-by-entry-id So my question is, if the form id is 5 and an entry id is say 23, and the field to be updated is 237, how would one form the REST request properly to have that field updated in the entry? Any suggestions or tips are welcome.  
Mike Harding replied 7 months ago

I have been making some headway on this topic using curl to test from the remote computer. When I use the methods POST, PUT, or PATCH it is creating a new form entry rather than updating the existing form.

Here is a sanitized version of the curl command:

curl -u MYAPIKEY:x -X PATCH -H "Content-Type: application/json" https://my.server.com/wp-json/frm/v2/forms/5/entries -d '{"id":"23","item_key":"saihy","contract":"187022","template":"Light Template","layout":"Left Menu Bar","dmurl":"https://someplace.com/"}'

So the amended question is, how can I update an entry vs. create a new entry using the REST API?

Mike Harding replied 7 months ago

In the case this will help any one else, here is the solution.

The issue was the URL, it needed to point to /wp-json/frm/v2/entries to update.

Using the sample I had above would create a new instance of the record.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right