Building REST requests
The REST request interface in Superblocks makes it easy to send HTTP requests to any API. Whether you're using an internal API, or integrating with a third-party's API, send any request you want to retrieve, add, delete, or update data using REST.
The REST request interface will appear when you add any of the following types of steps to your APIs:
- Standalone REST API step
- Generic REST API integration
- A SaaS integration, like Airtable, Zendesk, or Slack
Superblocks' REST requests support a range of Actions that you can select from to configure what operation your API step will perform.
For REST based integration, the default action is often set to Generic HTTP request, which you can use to fully customize the request being made.
For a faster development experience, select one of the pre-configured Action endpoints. When you select an endpoint, the Method and URL will be automatically set, along with any required Query parameters and Headers needed for the request.
The request form
The REST request form include all the configurations needed to connect to a webserver and execute your request. Every request needs a URL and method. Specify additional details based on the requirements of the endpoint you're calling.
Select the method for the request from the dropdown. If you selected an action from the actions this will be selected for you, otherwise the
GET method is selected by default. You can use a variety of methods, including
GET- retrieve data
POST- add new data
PUT- replace existing data
PATCH- update some existing data fields
DELETE- delete existing data
Each request requires a URL representing the endpoint you want to call. Add the endpoint manually, or have it pre-filled by selecting an API endpoint in the actions. When using an integration, the Base URL will be set for you based on the integration configuration.
Send query parameters with your request by adding them directly to the URL or as key-value pairs in the Query parameters section. When using an API endpoint from the list of pre-configured actions, any required query parameters will be automatically added to the request form for you.
Use the Body section to specify the data you want to send with your request. You can send different types of body data to suite your API. Choose the data type you need based on the expected request body for the API endpoint.
Use the JSON body type to send JSON data to your API. The JSON body data field supports syntax-highlighting, as well as commenting by using the
// for single-line deliminted comments, or
/* */ for multi-line.
An example request body that matches the API's required schema will be automatically added for you when using pre-configured actions.
Use the Raw body type to send anything you can enter as text.
Be sure to add the appropriate
Content-Type header to the Headers section based on the type of content you're sending in your request.
Website forms often send data to APIs as
multipart/form-data. Replicate this using the REST request Form body type. Form data lets you send key-value pairs and specify the content-type of each item.
Attach files to form data by setting the item's content-type to
File, then provide a filename and file content. Content can either by manually created, or read the content of the FilePicker component.
Some APIs require you send particular headers along with the request. You can set these in the Headers section. Enter a key-value pair of the headers up send with your requeset.
Superblocks automatically adds certain headers for you based on your selects and how you've configured your integration. Select hidden next to the Headers label to view the generated headers.
The response section
Once your API has run, you can view the response from you API in the repsonse section. Response section includes:
- Result - Shows the payload returned by the API along with the request status and timing
- Request - The full request executed by the backend shown as a CURL request.
The doc explorer
The doc explorer located to the right of the request form makes it easy to build your request at lighting speed. From here you can:
- Explore available endpoints - Search list of all of the available endpoints to choose from in the Actions menu
- View documentation - When you select an endpoint Action, the Doc Explorer snaps to that endpoint's documentation. Docs provide valuable information like the required headers and query parameters, the request schema and examples, responses schemas and codes the endpoint uses, and sometimes even scopes needed to access the endpoint.
After running your API, you'll see any errors returned by your request in the response section of the request form.
If your REST request is behaving as expected, there can be many possible reasons. This guide discusses how to troubleshoot and provides common issues and their causes.
This guide specifically discusses troubleshooting REST requests. To troubleshoot issues with the Superblocks platform, see our general Troubleshooting guide.
Debugging your requests
Since APIs in Superblocks run on a backend web server, you won't be able to see your REST requests in your browser's console. To debug REST requests issued in the backend, Superblocks provides you the full request as a CURL command in the Request tab of the response section. Use this command to debug issues with your request by copy/pasting it to your terminal or a REST client like Postman.