1- #include < SlicingDice.h>
1+ #include " SlicingDice.h"
22#include < ArduinoJson.h>
33
4- SlicingDice sd = SlicingDice(" mytoken" );
4+ // Demo API key, if you need a new demo API key visit: https://panel.slicingdice.com/docs/#api-details-api-connection-api-keys-demo-key
5+ String apiKey = String(" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMThtIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MTc5LCJjbGllbnRfaWQiOjEwfQ.OTb6REW9JtYF9wVUZhXajq4wheU5ULNbM5iEmMCYhhM" );
6+ const char * host = " api.slicingdice.com" ;
7+ int port = 80 ;
8+ // if false will use test end-point, otherwise production end-point
9+ int useProduction = false ;
10+ SlicingDice sd = SlicingDice(apiKey, host, port, useProduction);
511
612void setup () {
713 // Open serial communications and wait for port to open:
@@ -11,8 +17,8 @@ void setup() {
1117
1218 // Arduino network settings, should match your internet connection properties
1319 byte mac[] = { 0xDE , 0xAD , 0xBE , 0xEF , 0xFE , 0xED };
14- byte ip[] = { 192 , 168 , 1 , 10 };
15- byte gateway[] = { 192 , 168 , 1 , 1 };
20+ byte ip[] = { 192 , 168 , 0 , 10 };
21+ byte gateway[] = { 192 , 168 , 0 , 1 };
1622 byte subnet[] = { 255 , 255 , 255 , 0 };
1723 byte dnxs[] = { 8 , 8 , 8 , 8 };
1824 Ethernet.begin (mac, ip, dnxs, gateway, subnet);
@@ -24,8 +30,9 @@ void loop() {
2430 JsonObject& queryIndex = jsonBuffer.createObject ();
2531 JsonObject& nestedQueryIndex = queryIndex.createNestedObject (" user1@slicingdice.com" );
2632 nestedQueryIndex[" age" ] = 22 ;
33+ queryIndex[" auto-create-fields" ] = true ;
2734 sd.index (queryIndex);
2835 Serial.print (" Status code: " );
2936 Serial.println (sd.statusCode );
3037 Serial.println (sd.response );
31- }
38+ }
0 commit comments