Title: Pull data from external server using a Form, REST API &amp; JSON
Last modified: September 13, 2023

---

# Pull data from external server using a Form, REST API & JSON

 *  [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/)
 * Hi. I was asked to create a form that, when filled out and submitted, would pull
   data from an external server to show in a new or same page. Basically like the
   results you get on [this page](https://www.deltadental.com/us/en/member/find-a-dentist/dentist-search-results.html?)
   on a dental insurance site. They would like to display the contact info, which
   is far less info than on that link, as well as the map and said they would set
   up a JSON file for the site to send/receive the info from their server. Using
   JSON wrappers and POST method, they mentioned that I may only need an id to make
   this happen, but I’ve never done this before. I’ve seen a couple of form plugins
   that use a REST API attribute, but not sure if that would be the same thing or
   if that’s even what I’m looking for, but the client did say we should also be
   using REST API. Are there any good ways to go about creating this page in an 
   existing WordPress site? Thanks in advance for anyone who can help.

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

 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17048392)
 * You can use wp fetch in your javascript that will be handling the form, something
   like
 *     ```wp-block-code
       # in your PHPcode
       wp_enqueue_script( 'your-script', 'yourscriptpath/script.js', array( 'wp-api','wp-api-fetch' ), 'your version', false );
   
       # in your script.js  that handles the form
   
       wp.apiFetch({
           url: remoute/url,
           method: 'POST', 
       }).then(response => {
           // Handle the response
           console.log('response:', response);
           // Display the lookup results on the page
           // ...
       }).catch(error => {
           // Handle any errors
           console.error('Error performing lookup:', error);
       }).finally(() => {
           // do anything else
       });
       ```
   
 *  Thread Starter [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17049320)
 * Thank you for your response [@alanfuller](https://wordpress.org/support/users/alanfuller/)
   I’ve been looking it over and I’m starting to wonder if this is too far over 
   my head. The way they made it sound, it didn’t seem too difficult. However, I
   am not great with Java or PHP, so this code, as much as I appreciate it, doesn’t
   seem very understandable to me. I don’t know where to start with this, even tying
   it into a form, which I assumed I would create using a plugin like CF7 or something
   else. Thanks again, and if you or anyone else has any other advice that can help,
   please let me know.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17049998)
 * It is fairely straight forward for a PHP / Javascript developer. Perhaps your
   clients mis understood your skill set.
   The only advice I can give you is to be
   honest with your client such custom development is outside your experience.
 *  Thread Starter [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17050821)
 * Thanks. Yes, I have been open and honest with them. They are just asking me to
   try, and with a little bit of experience altering the PHP/Javascript code, I 
   just thought I would ask. Sounds like this is the only way to go about doing 
   this, so I will research what you mentioned to see if there’s any elaboration
   out there about it and go from there.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17050884)
 * There are non code approaches too.
   Being a development forum I assumed developer
   skills.However, using a (probably premium) form plugin and services like Zapier
   you probably could configure a solution without code.
 *  Thread Starter [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17052433)
 * [@alanfuller](https://wordpress.org/support/users/alanfuller/) You’re absolutely
   right, but I didn’t know where else to ask about this. I feel like I know quite
   a bit about WordPress, but certainly know that there are PHP and Javascript developers
   out there that know waaaaaay more than I do. That’s why I come to the community
   to ask questions… because I know I’ll get great answers. I appreciate the reply
   about Zapier. I am going to look into that as well as the first method you gave
   in order to hopefully improve my skills and do it the right way. Thanks again
   for all of your replies. Really appreciate it.
 *  Thread Starter [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17120589)
 * Just thought I’d bump this question to see if anyone else had any other ideas,
   since I have pretty much been stumped, even with Alan’s help. I just don’t understand
   where to put that code and how to use it with a contact form plugin, like CF7.
   If so, great, and I would appreciate it. If not, then thanks anyway for reading.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17120892)
 * May I remind you of the do not bump guideline [https://wordpress.org/support/guidelines/#do-not-bump-posts](https://wordpress.org/support/guidelines/#do-not-bump-posts)
   
   It is horrible when a client asks you to do something beyond your capabilities,
   and my previous advice stands, tell the client this job is not for you.However
   there are a couple of other approaches1) if the client is paying enough, outsource
   the development2) AI is actually very good at giving technical /coding guidanceUsing
   this prompt`using wp.api_fetch show me an example of how on submission of contact
   form 7 I can integrate javascript to make and API call`on Chat GPT you get a 
   pretty reasonable starter with explantations
    -  This reply was modified 2 years, 7 months ago by [Alan Fuller](https://wordpress.org/support/users/alanfuller/).
    -  This reply was modified 2 years, 7 months ago by [Alan Fuller](https://wordpress.org/support/users/alanfuller/).
 *  Thread Starter [dsb0328](https://wordpress.org/support/users/dsb0328/)
 * (@dsb0328)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17121983)
 * Oh wow. I didn’t even know there was a “no bump” policy. I had just taken your
   previous advice, researched some, was still confused, didn’t see a different 
   place to ask this question in the forums, and, instead of repeating the question,
   thought it better to just ask here again. My apologies. But thanks for the advice
   about Chat GPT. Hadn’t even thought about using AI. Also, I don’t know anyone
   else that can do this, so I can’t source it out. That’s why I’m asking here.
 *  [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * (@alanfuller)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17122225)
 * It is better to start a new thread even if it is very similar it you are not 
   getting the input you need from the volunteers already on the thread.
   The way
   the support volunteers work is first they look at the unanswered questions and
   pick the one they may be able to help on. So if my input is not getting you anywhere,
   feel free to repost but with perhaps narrower input, like for instance be specific
   you are trying to integrate to CF7 etc. ( I wont be offended if I see such a 
   post I’ll leave it for other volunteers to look at )

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

The topic ‘Pull data from external server using a Form, REST API & JSON’ is closed
to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 10 replies
 * 2 participants
 * Last reply from: [Alan Fuller](https://wordpress.org/support/users/alanfuller/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/pull-data-from-external-server-using-a-form-rest-api-json/#post-17122225)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
