Skip to main content
All CollectionsCustom endpoints
What are request variables?
What are request variables?

How can I use incoming request data?

Robert van Boesschoten avatar
Written by Robert van Boesschoten
Updated over a year ago

Warning!

This is a legacy document. The features described below are only usable within the classic-generation environment.

Currently, Betty Blocks offers faster and more advanced options that are available in next-gen. Before you start working on some new features in your application, consider doing it using the next-gen version. In particular, you might find it useful to check out Getting started with data API article.

Good luck!


After reading this article you will know:

  • What request variables are

  • How to setup a request variable

  • How to use request variables

When a web browser loads a web page, it sends a request to the server for the page. The most common request is a GET request, which simply requests a web page. When a user performs such a request, they send certain variables back to the server, such as their IP address, what browser they're using and what web page they came from. You can save these variables in a custom model by setting up a request variable! 

Whenever you set up a request variable, a custom model is assigned or generated for the page. The custom model can be viewed and altered at the custom models overview of your app (Tools > Custom Models). The default properties are:

  • client_ip

  • query

  • client_cert_info (collection of other attributes)

  • params (collection of other attributes)

  • uri

  • method

  • body

  • headers (collection of other attributes)

The standard request variable's custom model's JSON is as follows:

How to create request variables

You can only create request variables on pages and endpoints, so let's start by opening one up.

Once you've opened the endpoint you want to add a request variable to, scroll to the bottom of the form and enter in "Request variable as".

You can now press enter and that'll be that! That's all you need to do to use them. You might notice that a new input variable has been created, named the same as the request variable. This input variable has been automatically generated, as by pressing enter without selecting our own, Betty Blocks was forced to generate a custom model for our request variable to use. You can also create you own by editing the request variable.

Using request variables

You can use your request variables just like any other custom model. You can access them using the variable browser.

You can use your request variable in Liquid the same way you would in a text expression by removing the var: and surrounding it with curly brackets, like so

{{request.client_ip}}
Did this answer your question?