Update Entry Via API?

By: Michael Clark | Asked: 07/26/2022
ForumsCategory: How-toUpdate Entry Via API?
Michael ClarkMichael Clark asked 2 years ago
Want to update entries dynamically, via API, with the View shortcode as the Notification URL:
sitename.com/wp-json/frm/v2/entries/[display-frm-data id=view_id myparam="[field_id]"]
When I hard code the entry to update via API, it works. When I test the View parameter, the filter works. When I use the View shortcode as the Notification URL as noted above, the update does not work and the logs say: "No route was found matching the URL and request method." It's like the shortcode as the end of the API Notification URL gets stripped out or ignored.  Verified everything according to the Formidable docs here , and I've validated every possible way of dynamically retrieving an entry with that View and they all work. Can anyone shed some light on how I can update entries dynamically via API (or some other way :| )? Greatly appreciated.
Question Tags:
2 Answers
Best Answer
Chris Adams answered 2 years ago
Hi Michael, I have tried the above method once, and it worked ok, but i find a much easier method is to save the entry ID in a hidden field when the entry is created and then just use that with the API instead of the view. https://formidableforms.com/knowledgebase/frm_after_create_entry/#kb-save-the-entry-id-in-a-field If you can't do that (you may already have entries in the form etc) then i'd go back and re-check all of the steps in the process one more time. If you have the Visual Views installed i'd also check the view settings to make sure it's not wrapping the ID in <p> tags or anything like that.
Michael ClarkMichael Clark replied 2 years ago

Thanks for the suggestions, Chris. The entry ID is the crux and I appreciate the fact that you understood and reinforced the need to focus on solving that.

Since need to update entries in a form with 256 entries in it, the API route is my path to joy! Hopefully. I've re-verified and validated all the steps as suggested and have definitely discovered the failure, and am unable to fix it, since I'm not as skilled a coder as I'd need to be to code a workaround or a patch.

Good thing that Formidable provides multiple ways to achieve tasks, though. There's more than one way to build the Notification URL used by the API action. Yay!

Carlo Santos replied 1 year ago

Hi Chris,

Could you share how you overcame this problem? I need to obtain a dynamically created Entry ID from another form.

Chris AdamsChris Adams replied 1 year ago

Hi Carlos,

If i need to update an entry via the API then i store the entry ID in a hidden field when the entry is created using this: https://formidableforms.com/knowledgebase/frm_after_create_entry/#kb-save-the-entry-id-in-a-field

Once you have the entry ID in a field you can use it in the same form in the API action or if you need to use it in another form you can pull it in with a Lookup field.

Hope that helps

Michael ClarkMichael Clark answered 2 years ago
Since the Notification URL in Formidable's wonderfully powerful API action can be a shortcode, you can make your own shortcode or use Formidable's internal ones to build a dynamic URL for updating entries in another form. I was unsuccessful at many attempts to use a View filtered by a value in a shortcode, but I could achieve the desired dynamic URL by ensuring the correct REST endpoint was appended with the correctly formatted/url-encoded value.   Steps: 0. Have a way to simply verify the API calls. I always start with Formidable's on Logs extension. 1. Make sure your desired endpoint is there and accessible over https:// 2. Append an entry ID to the end of that (in my case, anyway) to validate you still get a status of 200. 3. Build a shortcode that has the end point and your desired method for retrieving your dynamic ID. 4. Test the shortcode 5. Put the shortcode in the Notification URL of the desired form's API action 6. Test the action, refine as needed. 7. Dial back any exponential increase in anxiety meds and/or alcohol consumption (optional). ;) 

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