'KSQL Rest INSERT not inserting

I have created a KSQL table with the following command:

ksql> CREATE TABLE CUSTTABLE (id INT PRIMARY KEY, name VARCHAR, purchase VARCHAR) WITH (KAFKA_TOPIC = 'CUST_TOPIC', VALUE_FORMAT = 'JSON')

If I use the ksql cli I can insert values into the table with a command like:

ksql> INSERT INTO CUSTTABLE VALUES (1, 'John Smith', 'Stuff')

However if I try to us a python rest call similar to:

url = "http://0.0.0.0/ksql"
headers["Content-Type"] = "application/json"
query="INSERT INTO CUSTTABLE VALUES (1,\'John Smith\',\'Stuff\')"
data = '{"Ksql":"' + query + '"}'
resp = request.post(url, headers=headers, data=data)

Every response code is 200 but a SELECT * FROM CUSTTABLE only returns data entered into the table manually.

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source