JSON POST with runShellCommand

Hi All - Really hoping you can help. I've sunk a few hours in to this with a few various tutorials and guides but i'm hitting a brick wall.

My aim is to use Arduino to post to Slacks webhook - which in itself should be very straightforward. I have successfully posted to it using CURL in terminal and postmaster so API hook works.

Here is my for runCurl. I'm using the basis of the Process example.

void runCurl() {
  // Launch "curl" command and get Arduino ascii art logo from the network
  // curl is command line program for transferring data using different internet protocols
  Process p;       // Create a process and call it "p"
  p.runShellCommand("curl -X POST --data-urlencode 'payload={\"text\":\"This is a line of text.\nAnd this is another one.\"}' https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"); // Add the URL parameter to "curl"

  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
}

My issue is nothing is being logged in Slack. I'm wondering if:

  1. This is the best approach for posting to JSON - i cant find a simpler version
  2. Is there a known issue with runShellCommand
  3. Is my code wrong....

Pay attention there is a problem with BRIDGE and CURL commands if your arduino has REST API PASSWORD activated... Just deactivate Rest Api password and everything should work!

I've lost my mind for two days with the same problem

Thanks for the response Raxpa. I have checked and confirmed that my REST API access is deactivated. Still no luck.

I have changed approach now and trying to use simple HTTP request but still no joy.

Current code:

void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  Serial.begin(9600);

  while (!Serial); // wait for a serial connection
}

void loop() {
  // Initialize the client library
  HttpClient client;
  Serial.print("IN GERE" + String(client.available()));
  // Make a HTTP request:
  client.get("https://api.thingspeak.com/apps/thinghttp/send_request?&api_key=XXXXXXXX&message=payload={\"text\":\"ARDUINO.\"}");
  
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  Serial.flush();

  delay(5000);
}

If I ping this URL in the my browser it just works. This YUN is killing me :o

https://forum.arduino.cc/index.php?topic=344745.msg2376552#msg2376552

Using curl with https:

curl -h |grep certs
 -k, --insecureAllow connections to SSL sites without certs (H)

Warning: connections to SSL sites without certs defeat https complete.

https://forum.arduino.cc/index.php?topic=344745.msg2377171#msg2377171

Install ca-certificates !