Just started playing with a ESP32. Enjoyable so far..
I work in networks and we use www.zabbix.com to monitor routers etc.
Zabbix comes with a HTTP / JSON API.
When I post using:
for JSON:int httpResponseCode = http.POST("{\"jsonrpc\":\"2.0\",\"method\":\"apiinfo.version\",\"params\":\[]\,\"id\":\"1\"}");
Code: Select all
{
"jsonrpc": "2.0",
"method": "apiinfo.version",
"params": [],
"id": 1
}
However when I post:
for JSON:int httpResponseCode = http.POST("{\"jsonrpc\":\"2.0\",\"method\":\"item.update\",\"params\":\{"itemid":"42244","status": 0},"auth":\"xxxxxx\",\"id\":\"1\"}");
Code: Select all
{
"jsonrpc": "2.0",
"method": "item.update",
"params": {
"itemid": "42244",
"status": 0
},
"auth": "xxxxxx",
"id": 1
}
It appears to be how I am presenting the (nested?) JSON in the parameters section(?). Tried many ways but research such as google: esp32 httpclient unable to find string literal operator 'operator has not been successful.int httpResponseCode = http.POST("{\"jsonrpc\":\"2.0\",\"method\":\"item.update\",\"params\":\{"itemid":"42244","status": 0},"auth":\"xxxxxx\",\"id\":\"1\"}"); ^~~
exit status 1
Compilation error: unable to find string literal operator 'operator""itemid' with 'const char [52]', 'unsigned int' arguments
Any ideas or pointers to the correct answer?
Many thanks
Aidan