Sending PUT request to local server

Hello everyone!

We have some trouble sending a put request to a local server, we would like to modify a json file of our local server.
We tried to modify the code given in the example of the ArduinoHttpClient library to adapt it to our problem.
We are not sure how to use the client.put command and what it takes as arguments (and the contentType).
When we run the code we get a 400 error.

Thank you very much (and please be comprehensive, we are newbies :wink: )

#include <ArduinoHttpClient.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>
#include "arduino_secrets.h"

/////// Wifi Settings ///////
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;

char serverAddress[] = "x";
int port = 8080;

WiFiClient wifi;
HttpClient client= HttpClient(wifi, serverAddress, port);
int wl_status = WL_IDLE_STATUS;

void setup() {
  Serial.begin(9600);
  while ( wl_status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);

    // Connect to WPA/WPA2 network:
    wl_status = WiFi.begin(ssid, pass);
  }
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");   

  Serial.println(ip);
  client.println();
}

void loop() {
 
  Serial.println("making PUT request");
  String contentType = "application/json"; // Want to send a modified json 
  String putData = "{\"id\":3,\"name\":\"NOM\",\"forename\":\"PRENOM\",\"dehydrationState\":0,\"heartbeat\":0}";

  client.beginRequest();
  client.put("http://localhost:8080/demo/patient/3", contentType, putData);// want to modify the json in our database on a local server
  client.endRequest();
  // read the status code and body of the response
  int statusCode = client.responseStatusCode();
  String response = client.responseBody();

  Serial.print("Status code: ");
  Serial.println(statusCode);
  Serial.print("Response: ");
  Serial.println(response);

  Serial.println("Wait five seconds");
  delay(5000);
}
  client.put("http://localhost:8080/demo/patient/3", contentType, putData);// want to modify the json in our database on a local server

I doubt that the server is running on the Arduino, so localhost as the host name is definitely wrong here.