HISE Logo Forum
    • Categories
    • Register
    • Login

    Server API Request METHOD

    Scheduled Pinned Locked Moved General Questions
    7 Posts 4 Posters 448 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sakorada
      last edited by

      How can we send requests using Server API with (PUT , DELETE.......) methods?

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @sakorada
        last edited by

        @sakorada - read the documentation its in there...

        HISE Development for hire.
        www.channelrobot.com

        S 1 Reply Last reply Reply Quote 0
        • S
          sakorada @Lindon
          last edited by

          @Lindon I can find only callWithGET and callWithPost ,no other Method
          https://docs.hise.audio/scripting/scripting-api/server/index.html#callwithget

          d.healeyD orangeO 2 Replies Last reply Reply Quote 0
          • d.healeyD
            d.healey @sakorada
            last edited by

            @sakorada That's all we have. If you want more complicated functionality you need to implement that server side and trigger it with the post/get requests.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            1 Reply Last reply Reply Quote 0
            • orangeO
              orange @sakorada
              last edited by orange

              @sakorada said in Server API Request METHOD:

              @Lindon I can find only callWithGET and callWithPost ,no other Method
              https://docs.hise.audio/scripting/scripting-api/server/index.html#callwithget

              Normally, All of the included methods are enough. Even if you want to delete something, you'll need to use callWithPOST. And you need to arrange the endpoint link in your server for the delete process that used with callWithPOST.

              Why do you need Put / Delete stuff?

              Which system are you using on your server or hosting? Wordpress / Woocommerce?

              develop Branch / XCode 13.1
              macOS Monterey / M1 Max

              S 1 Reply Last reply Reply Quote 0
              • S
                sakorada @orange
                last edited by

                @orange I used callWithGet and callWithPost just fine with my current PHP API (From My Website), but I'm going to move to Serverless (AWS ...Lambda Function and stuff).
                and I just wondering if we had implemented (PUT, DELETE....) so I don't have to make requests with POST for everything.
                But yes, maybe I have to stick to POST then...

                1 Reply Last reply Reply Quote 0
                • S
                  sakorada
                  last edited by

                  One more thing I noticed: Server API request data is not JSON format.
                  I tried to do

                  Server.setHttpHeader("content-type: application/json");
                  

                  and still doesn't work.

                  var data = {
                              "name": "Iron Man",
                              "status": "Gone gone"
                             };
                     
                      
                  Server.setBaseURL("https://postman-echo.com/post");    
                  Server.callWithPOST("/", data, function(status, response) {
                          Console.print(status);
                          if (status == Server.StatusOK) {
                               payload = response;
                              Console.print(JSON.stringify(response));
                          }
                      });
                  
                  //echo back from server------------------------------------------------------------------------
                  {
                    "args": {
                    },
                    "data": "name=Iron%20Man&status=Gone%20gone",
                    "files": {
                    },
                    "form": {
                    },
                    "headers": {
                      "x-forwarded-proto": "https",
                      "x-forwarded-port": "443",
                      "host": "postman-echo.com",
                      "x-amzn-trace-id": "Root=1-60f17642-6b42c7eb593222a77e103b8c",
                      "content-length": "34",
                      "accept": "*/*",
                      "content-type": "application/json",
                      "user-agent": "juce",
                      "cache-control": "no-cache"
                    },
                    "json": null,
                    "url": "https://postman-echo.com/post/"
                  }
                  
                  var data = {
                              "name": "Iron Man",
                              "status": "Gone gone"
                             };
                     
                      
                  Server.setBaseURL("https://postman-echo.com/post");
                      //Try to Set content-type to application/json
                  Server.setHttpHeader("content-type: application/json");
                      
                  Server.callWithPOST("/", data, function(status, response) {
                          Console.print(status);
                          if (status == Server.StatusOK) {
                               payload = response;
                              Console.print(JSON.stringify(response));
                          }
                      });
                  
                  //echo back from server------------------------------------------------------------------------
                  {
                    "args": {
                    },
                    "data": "name=Iron%20Man&status=Gone%20gone",
                    "files": {
                    },
                    "form": {
                    },
                    "headers": {
                      "x-forwarded-proto": "https",
                      "x-forwarded-port": "443",
                      "host": "postman-echo.com",
                      "x-amzn-trace-id": "Root=1-60f176e9-3369eaac39072e93338cd563",
                      "content-length": "34",
                      "accept": "*/*",
                      "content-type": "application/json",
                      "user-agent": "juce",
                      "cache-control": "no-cache"
                    },
                    "json": null,
                    "url": "https://postman-echo.com/post/"
                  }
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post

                  47

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.9k

                  Posts