Using the API Connector With Your Own Endpoints

Since I wasn’t able to find a clear answer to this on the forum, I wanted to share with you guys how and why I ended up using the API Connector to my own endpoints.

For the most part, I try to limit the workflows for my apps to state changes and scheduling API workflows - this improves speed and scalability. In this case, I was having user’s “download” a list of restaurants to their acount (really, I was running a search that was taking a while to complete). I wanted to show a progress bar, and the only way to do that is by using the API Connector (as scheduling an API workflow processes on the backend).

To do this:

  1. Set up your API Endpoint as normal

  2. In the API Connector, your format will be

  • Name: [your_API_Endpoint_name]

  • Us as: Action

  • Data type: JSON

  • POST

  • https://yourdomain.com/version-test/api/1.1/wf/your_API_endpoint_name

  • Add a header with a key of Content-Type and value of application/json

  • The body will look something like this:
    {"parameter_name": "<parameter_name>"}

  • Make sure to mark your Body parameters as not private

  • Put in some example values for the parameters, and initialize the call (remove the values after)

There you go! You can now use your set up API under the plugins area when creating a workflow, and pass through dynamic values.

5 Likes

Cool idea I like it.

I’d just like to say, “thank you”, as this bit of information just stopped me tearing my hair out:

I was calling my own endpoint for various reasons and it kept failing to see the parameters I was sending. I couldn’t figure out why and started google-whacking, only to discover your post. Adding the content type was the step I had missed.

1 Like

Happy to help!

Note on a part I got confused about when trying to do this years later: you don’t add parameters. You add JSON in the Body (JSON object) part, which creates the ability to fill in dynamic values.

Screenshot of how mine is working:

Backend workflow:

API Connector

This basic setup has been hugely helpful in lots of apps I’ve created. Little tip for anyone reading this thread in the future:

Instead of this:
https://yourdomain.com/version-test/api…”

You can use something like this:
“[homeURL]api/1.1/…”

That way, you can just pass the “Website home URL” data source as a parameter, making it easier to use if you need to differentiate between live & test versions - For example, if you need to access something from your database.

2 Likes

Nice, love this!