No internet connection
  1. Home
  2. How to

Curl request directly from soundflow

By Dylan Barber @Dylan_Barber
    2023-05-27 19:14:29.067Z

    Hi,

    I'm not sure if this is even entirely possible, but I am wondering how I would go about submitting a curl request via an API directly from an SF script? This is for a smart bulb (but not Philips Hue).

    Any ideas?
    Thanks!

    • 5 replies
    1. D
      Dylan Barber @Dylan_Barber
        2023-05-28 15:24:28.741Z

        To elaborate on this a little more, I essentially want to tell one of my smart bulbs (used with Tuya Smart Life) to turn on and go red whenever Pro Tools or Logic goes into record mode. If that is even possible?

        1. In reply toDylan_Barber:

          Hi Dylan,

          You can make HTTP requests straight from SF -
          Here's a pseudo example:

          
          sf.net.httpRequest({
              url: `http://127.0.0.1:1000/blabla`,
              method: 'POST',
              data: {
                  some: true,
                  json: 'blabla',
                  data: 1234,
              },
          });
          
          
          1. DDylan Barber @Dylan_Barber
              2023-05-29 11:20:55.823Z

              Thanks for the info Christian! Super helpful. One more Q I think (famous last words...); where would I put the header information for the request? in the url line?

              1. There's a property called "headers" for httpRequest - example:

                sf.net.httpRequest({
                    url: `http://127.0.0.1:1000/blabla`,
                    method: 'POST',
                    headers: {
                        'Authentication': 'Bearer blablabla',
                    },  
                    data: {
                        some: true,
                        json: 'blabla',
                        data: 1234,
                    },
                });
                
            • In reply toDylan_Barber:

              If you wanna go via CURL that's also possible (but less performant/flexible):

              sf.system.exec({
                  commandLine: `curl .....`,
              });