/
Calling IguanaX APIs
Calling IguanaX APIs
Calling IguanaX APIs locally:
If you are calling Iguana’s APIs from a Translator within the same Iguana instance, you can use the iguana.call()
function to call the API. This allows you to quickly call the desired API without having to authenticate.
When performing actions on targeted components, you can provide a list of component names or GUIDs to identify components. However, best practice is to use the component GUID as these are permanent IDs where as a component name can be modified.
Calling IguanaX APIs externally:
If you are calling Iguana’s APIs from outside of Iguana or from a different Iguana instance, you will need to use the net.http.*
and authenticate before making API requests. This involves three steps:
Try this out in the Translator with the following code:
local function login(Credentials)
-- url-encoded POST parameters
local _, _, header = net.http.post{
url = '127.0.0.1:7654/session/login',
parameters = Credentials,
live = true
}
-- return only the set cookie from header
return header["Set-Cookie"]:split(';')[1]
end
local function logout(Cookie)
net.http.post{
url = '127.0.0.1:7654/session/logout',
headers = {['Cookie'] = Cookie},
live = true
}
end
function main()
local credentials = {
username='admin',
password='password'
}
-- Log in and get a session cookie
local cookie = login(credentials)
-- Call an Iguana X API using the cookie
local componentList = net.http.post{
url = '127.0.0.1:7654/component/list',
headers = {['Cookie'] = cookie},
live = true
}
local componentList = json.parse{data=componentList}
-- Make more API calls with the cookie
-- Log out
logout(cookie)
end
, multiple selections available,
Related content
Introduction IguanaX's APIs
Introduction IguanaX's APIs
More like this
How to discover IguanaX APIs?
How to discover IguanaX APIs?
More like this
Configuring Iguana
Configuring Iguana
More like this
Programmatically get an Iguana ID
Programmatically get an Iguana ID
More like this
Install IguanaX in Docker
Install IguanaX in Docker
Read with this
IguanaX Change Log
IguanaX Change Log
Read with this