POST REQUEST with MKR1010

Hello,

I am aiming to make a post request to trigger a IFTTT webhook action.
I am using the MKR1010 board.
I am able to connect to the network and turn the connected LED on and off using the cloud integration.

The code is as follows, but doesn't trigger the web hook. I can manually paste the web address in a browser and this does trigger the web hook.

The key has been replaced in the below code with a dummy value.

Does anybody know why this is not triggering the web hook? / Can you explain why the post request is not being made. I don't even really need to read the response from the server as long as it is sent.

Thank you

#include "thingProperties.h"
#include "WiFiNINA.h"

#define LED_PIN 13
#define BTN1 6

// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;


// variables will change:
int btnState = 0;         // variable for reading the pushbutton status
int btnPrevState = 0;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  // setup the board devices
  pinMode(LED_PIN, OUTPUT);
  pinMode(BTN1, INPUT);
  

}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  // read the state of the pushbutton value:

btnState = digitalRead(BTN1);
if (btnPrevState == 0 && btnState == 1) {
 led2 = !led2;
 postrequest();
}
  digitalWrite(LED_PIN, led2);
    
btnPrevState = btnState;

}



void onLed1Change() {
  // Do something
  
   digitalWrite(LED_PIN, led1);
    //Serial.print("The light is ");
    if (led1) {
        Serial.println("The light is ON");
    } else {
    //    Serial.println("OFF");
    }
    

}

void onLed2Change() {
  // Do something

  digitalWrite(LED_PIN, led2);
}


void postrequest() {
/*

    // connect to the Maker event server
    client.connect("maker.ifttt.com", 443);

    // construct the POST request
    
char post_rqst[] = "POST /trigger/btn1press/with/key/mykeyhere";

Serial.println(post_rqst);

    // finally we are ready to send the POST to the server!
    client.print(post_rqst);
    client.stop();
*/  
WiFiClient myClient;

  if (myClient.connect("maker.ifttt.com", 443))
  {
  Serial.println("Connected to ifttt !");
   
    myClient.print 
    (
      String("POST /trigger/btn1press/with/key/mykeyhere")
   //postData   
    );
  Serial.println("Post Sent");
  
   
    while(myClient.available()==0)//wait until data reception
    {
      ; // you can add a counter and break if you exceed a value
    }
    while(myClient.available()) //write all incoming data characters on serial monitor
    {
      
      Serial.write(myClient.read());     
    }
  }
}