ADMIN
users can make HTTP requests in the Profile mappers assistant drawer.
Enter http.
followed by get
, post
, put
, or delete
. It is possible to add the following optional methods:
.body()
-
.clientCertificate()
-
.header()
It is safe to include credentials. The JavaScript code runs in the backend of Fluid Topics.
-
.connectTimeout()
-
.responseTimeout()
Both
connectTimeout
andresponseTimeout
take values in milliseconds. -
.send()
-
.sendAsync()
- The
.send()
and.sendAsync()
methods give access to response methods. .sendAsync()
returns a promise.- When making API calls to the portal itself, it is possible to use the
baseUrl
variable. Fordoc.fluidtopics.com
, thebaseUrl
value ishttps://doc.fluidtopics.com/
.
- The
POST fictional example using .send()
:
try {
const response = http.post('https://example.com/api/accounts/create')
.header('Content-Type', 'application/json')
.body(JSON.stringify({
"example": "value"
})).send();
const responseBody = response.asString();
const jsonData = JSON.parse(responseBody);
console.log(JSON.stringify(jsonData, null, 2));
} catch (issue) {
console.error('An error occurred:', issue);
}
POST fictional example using .sendAsync()
:
http.post('https://example.com/api/accounts/create')
.header('Content-Type', 'application/json')
.body(JSON.stringify({
"example": "value"
}))
.sendAsync()
.then(response => {
return response.asString();
})
.then(responseBody => {
const jsonData = JSON.parse(responseBody);
console.log(JSON.stringify(jsonData, null, 2));
})
.catch(issue => {
console.error('An error occurred:', issue);
});