window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-106914152-1');

Using Formidable Forms to Add Issues to GitHub

>>Using Formidable Forms to Add Issues to GitHub

I manage an intranet website for an office at the VA and recently I was asked if a form that I created could send the data to GitHub instead of just an email. My initial answer was no, until I learned that the form plugin (Formidable Forms) had an API addon that would allow me to connect with the GitHub API. Easy right? Due to some poor documentation and my apparent lack of understanding, not as easy as I thought. I am happy to say, after two weeks of intermittent work on this effort, I was successful. The remainder of this post is intended to help others take care of this in 15 minutes – yes, that easy if you know what you’re doing.

Prerequisites

Before you get started you need to have the right plugins installed. In order for this to work you must have Formidable Forms (I use Pro) and the Formidable API addon. While Formidable mentions the following in their documentation, I am here to tell you that the following tools are a must, at least initially. You should install the Formidable Logs plugin, you should use the Code Snippets plugin (you can use functions.php, but this is better), and install Postman.

Setting up GitHub and using the API

As I mentioned in the intro, I did this in order to use the GitHub API. I am not going to add a lot of detail about setting up an account because creating a GitHub account is pretty straight forward. Once you have an account established I recommend reading the basic of using the API and in particular the issues section.

Now you need to create a security token so that you can securely communicate with the API. To do that you need to go to your account>> Settings >> Developer Settings (at the bottom) >> Personal Access Tokens and then click Generate new token. Copy the token and save it for use in the next step (you can regenerate it if needed).

Writing the Snippet

The Formidable documentation on this is now fairly clear (updated as a result of my nagging) on how to create the necessary custom header information. It is all the way at the bottom of the page so you might miss it if you go there on you own. Referencing image 1, there are four key component:

Image 1. Screenshot of the formidable custom header

  1. A unique name for your function (no different than any other custom function)
  2. URL Argument – The endpoint of the call. This is optional, but I recommend tat you use it and be as specific as possible. This serves as a filter for requests and will only be called if the form endpoint (next section) and this entry match.
  3. Authentication Header – Add the authentication header and token value. This cause a lot of issues for me because the GitHub documentation never shows the correct format. The correct synatx is “Bearer your token value”. The word Bearer is critical as this is a bearer token.
  4. Accept Header – Add the GitHub MIME Type application/vnd.github.v3+json

When you are done it should look something like this:

Copy to Clipboard

 

Part 2 (because I am too distracted to finish it in one step) – Building the form is in draft and should be published shortly.

Featured image by Clément H

By |2018-12-09T11:05:21+00:00December 5th, 2018|Categories: Code|Tags: |0 Comments

About the Author:

Public servant, coder, amateur photographer, husband, father, grill master, cook, traveler, dreamer, and optimist. The order changes depending on the situation.

Leave a Reply

This website uses cookies and third party services. Any information collected is subject to the terms of service of those services. Other than comments you choose to leave, no information is collected or used by this website for any other purpose. Ok