Page tree
Skip to end of metadata
Go to start of metadata

In this article we will see how to request HTTP API resources and use it in Cally Square project.

Create script

Below you can see an example of script written in Perl language, but you can use your favourite language.

#!/usr/bin/perl -w

use strict;
use warnings;
use JSON qw( decode_json );

my $url = "";

my $curl=`curl -s '$url'`;
# { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }

my $decoded = decode_json($curl);

my $title = $decoded->{'title'};
print "SET VARIABLE RESULT_TITLE \"$title\"\n";

my $userId = $decoded->{'userId'};
print "SET VARIABLE RESULT_USERID \"$userId\"\n";

The script can be used as reference for your needs and remember to set properly the result of the cURL command:


Use script in Cally Square project

The script must be used as Command in AGI block:

And the variable set in the example.agi script will be available in Cally Square project.

As alternative of AGI Cally Square block, you can use System block assigning the result of the script as channel variable.

  • No labels