Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
olgaavalos
Partner - Contributor III
Partner - Contributor III

Connect Qlik to API REST

Hello,

I have the connection to the REST API, when trying to send the list X and Y in the body as a variable, it gives me an error that it does not recognize the input parameter that is being sent. Your help please.

 

When creating the connection, I put as parameters in RequestBody:
{
"X": [1, 2, 3, 4, 5],
"and": [2, 4, 6, 8, 10]
}
and in Query headers:
Content-Type application/json
When doing a connection test: Connection succeeded
But when trying to send as a variable inside the script I'm having problems:


LIB CONNECT TO 'REST_http127.0.0.15000predict';

// Define the X and Y strings in Qlik
let X = '1,2,3,4,5';
let y = '2,4,6,8,10';

// // Convert the strings X and Y to JSON strings
// let jsonData = '{"X": [' & X & '], "y": [' & Y & ']}';

// Make the POST request to the API using RestPost()
RestConnectorMasterTable:
SQL SELECT *
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
Url "$(url)",
HTTPHEADER "Content-Type" "application/json",
BODY "{"X":[$(X)],"y":[$(y)]}"
)
)
;

// Load the API results into a Qlik table
table:
LOAD *
RESIDENT RestConnectorMasterTable;

 

0 Replies