Hello all, I'm new to Arduino and I'm facing a problem. I have an Arduino Uno that calls an API on a local server, and it connects two it. However, it gets an empty result even though I test my API on postman and it works perfectly fine. on the serial I get an empty string Here is my API response on Postman:
{
"access:": 0
}
Here is my Arduino code:
#include <Ethernet.h>
#include <HttpClient.h>
#include <ArduinoJson.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 10, 10, 100);
IPAddress server(10, 10, 10, 102);
EthernetClient ethernetClient;
HttpClient httpClient(ethernetClient, server, 8000);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip);
while (Ethernet.begin(mac) != 1) {
Serial.println("Failed to configure Ethernet");
delay(5000);
}
Serial.println("Connected to Ethernet");
}
void loop() {
String url = "/pob/";
httpClient.get(url);
String response = httpClient.responseBody();
DynamicJsonDocument jsonDoc(1024);
deserializeJson(jsonDoc, response);
int value = jsonDoc["access"];
Serial.println(value);
}
Any ideas where my problem is?