HISE Logo Forum
    • Categories
    • Register
    • Login

    Help me understand Server.callWithPOST

    Scheduled Pinned Locked Moved Scripting
    26 Posts 3 Posters 666 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.
    • G
      guangcoder @d.healey
      last edited by

      @d-healey Thanks Bro for suggestion. Hise seem send text or something different, because server i tested on postman it work. But when try with Hise, it's always report "Status : 400", on server only receive: Empty Body: {}

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @guangcoder
        last edited by

        @guangcoder Your normalise function seems a bit janky. Just use myString = myString.replace(" "); and that will remove all spaces.

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

        G 2 Replies Last reply Reply Quote 0
        • G
          guangcoder @d.healey
          last edited by

          @d-healey I tried this, but it doesn't work:

          inline function normalizeString(input) {
              normalizedResult = normalizedResult.replace(" "); 
              local i = 0;
              while (i < input.length) {
                  local char = input.substring(i, i + 1);
                  if (char != " " && char != "\t" && char != "\n") {
                      normalizedResult = normalizedResult.replace + char;
                  }
                  i = i + 1;
              }
              return normalizedResult;
          }
          
          d.healeyD LindonL 2 Replies Last reply Reply Quote 0
          • d.healeyD
            d.healey @guangcoder
            last edited by

            @guangcoder You can delete your normalise function entirely, you don't need it. Use the built in String.replace function.

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

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

              @guangcoder

              like this....

              inline function verifyLicense() {
                  // Normalize data from inputs
                  local email = emailInput.get("text").replace(" ");
                  local productKey = productKeyInput.get("text").replace(" ");
              

              HISE Development for hire.
              www.channelrobot.com

              G 1 Reply Last reply Reply Quote 0
              • G
                guangcoder @d.healey
                last edited by

                @d-healey From server, it responded:

                Received Body:  {}
                Received Body:  {}
                Received Body:  {}
                Received Body:  {}
                Received Body:  {}
                Received Body:  {}
                Received Body:  {}
                

                It mean server don't understand json which was request by Hise, i check console print on Hise, I saw form was sent something like this: "email": abcd@gmail.com, "productKey": "1234abc", but server don't understand, so, it responded "status: 400"

                d.healeyD 1 Reply Last reply Reply Quote 0
                • d.healeyD
                  d.healey @guangcoder
                  last edited by

                  @guangcoder said in Help me understand Server.callWithPOST:

                  but server don't understand,

                  What is your endpoint expecting?

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

                  G 1 Reply Last reply Reply Quote 0
                  • G
                    guangcoder @Lindon
                    last edited by

                    @Lindon Thanks Bro, I will try!

                    1 Reply Last reply Reply Quote 0
                    • G
                      guangcoder @d.healey
                      last edited by

                      @d-healey endpoint is: "verify-license"

                      LindonL d.healeyD 2 Replies Last reply Reply Quote 0
                      • LindonL
                        Lindon @guangcoder
                        last edited by

                        @guangcoder said in Help me understand Server.callWithPOST:

                        @d-healey endpoint is: "verify-license"

                        and the API for this call is what?

                        HISE Development for hire.
                        www.channelrobot.com

                        G 1 Reply Last reply Reply Quote 0
                        • G
                          guangcoder @Lindon
                          last edited by

                          @Lindon I test on local server: http://localhost:3000/

                          1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @guangcoder
                            last edited by

                            @guangcoder said in Help me understand Server.callWithPOST:

                            @d-healey endpoint is: "verify-license"

                            But what data is it expecting?

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

                            G 1 Reply Last reply Reply Quote 0
                            • G
                              guangcoder @d.healey
                              last edited by

                              @d-healey said in Help me understand Server.callWithPOST:

                              But what data is it expecting?

                              My perpose is create a simple protection through API system, ask users Login with email and product key, then click verify, on server.js it insert available nfo (input by users). If match, set unlock GUI from Hise

                              d.healeyD 1 Reply Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @guangcoder
                                last edited by

                                @guangcoder But what data is the endpoint expecting you to send to it?

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

                                G 1 Reply Last reply Reply Quote 0
                                • G
                                  guangcoder @d.healey
                                  last edited by

                                  @d-healey said in Help me understand Server.callWithPOST:

                                  what data is the endpoint expecting you to send to it?
                                  Here is the way i apply Server.callWithPOST

                                  Server.callWithPOST("verify-license", payload, function(status, response) {
                                     
                                  });
                                  
                                  

                                  payload = email & product key

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @guangcoder
                                    last edited by

                                    @guangcoder Do you have some documentation for the end point you are calling that I can look at?

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

                                    G 1 Reply Last reply Reply Quote 0
                                    • G
                                      guangcoder @d.healey
                                      last edited by guangcoder

                                      @d-healey said in Help me understand Server.callWithPOST:

                                      Do you have some documentation for the end point you are calling that I can look at?

                                      Yes, sure:

                                      1. Verify License Endpoint
                                      • URL: /verify-license
                                      • Method: POST
                                      • Description: This endpoint receives a POST request with user data (email, product key, and system ID) and verifies the license validity. It returns the result indicating whether the license is valid.
                                      1. Request Payload
                                      • The payload sent to the server must be in JSON format and include the following fields:
                                        Example Payload:
                                      {
                                        "email": "user@example.com",
                                        "productKey": "XYZ123456",
                                      }
                                      

                                      Sure! Here's a concise English translation of the documentation:

                                      1. Verify License Endpoint
                                        URL: /verify-license
                                        Method: POST
                                        Description: This endpoint receives a POST request with user data (email, product key, and system ID) and verifies the license validity. It returns the result indicating whether the license is valid.
                                      2. Request Payload
                                        The payload sent to the server must be in JSON format and include the following fields:

                                      Field Type Description
                                      email string User's email address.
                                      productKey string User's product key.
                                      system_id string User's unique system identifier.
                                      Example Payload:

                                      {
                                        "email": "user@example.com",
                                        "productKey": "XYZ123456",
                                        "system_id": "SYSTEM_ID_1234"
                                      }
                                      
                                      3. Response
                                      - Successful Response:
                                      

                                      {
                                      "success": true,
                                      "message": "License valid! Activation successful."
                                      }

                                      - Unsuccessful Response:
                                      {
                                        "success": false,
                                        "message": "License invalid!"
                                      }
                                      
                                      1. HTTP Status Codes
                                      • 200 OK: Success. The success field in the response is true.
                                      • 400 Bad Request: Invalid request (e.g., missing or incorrect data).
                                      • 500 Internal Server Error: Server error (e.g., system or database issues).

                                      Sure! Here's a concise English translation of the documentation:

                                      1. Verify License Endpoint
                                        URL: /verify-license
                                        Method: POST
                                        Description: This endpoint receives a POST request with user data (email, product key, and system ID) and verifies the license validity. It returns the result indicating whether the license is valid.
                                      2. Request Payload
                                        The payload sent to the server must be in JSON format and include the following fields:

                                      Field Type Description
                                      email string User's email address.
                                      productKey string User's product key.
                                      system_id string User's unique system identifier.
                                      Example Payload:

                                      {
                                        "email": "user@example.com",
                                        "productKey": "XYZ123456",
                                      }
                                      
                                      1. Response
                                        The server will return a JSON object with the following fields:

                                      Field Type Description
                                      success boolean true if the license is valid, false if not.
                                      message string A detailed message about the verification result.
                                      Successful Response:
                                      {
                                      "success": true,
                                      "message": "License valid! Activation successful."
                                      }
                                      Unsuccessful Response:

                                      
                                      {
                                        "success": false,
                                        "message": "License invalid!"
                                      }
                                      
                                      1. HTTP Status Codes
                                      • 200 OK: Success. The success field in the response is true.
                                      • 400 Bad Request: Invalid request (e.g., missing or incorrect data).
                                      • 500 Internal Server Error: Server error (e.g., system or database issues).
                                      1. Example API Call
                                      var payload = {
                                          "email": "user@example.com",
                                          "productKey": "XYZ123456",
                                      };
                                      

                                      Server.callWithPOST("verify-license", payload, function(status, response) {
                                      if (status == 200) {
                                      if (response.success) {
                                      Console.print("License valid! Activation successful.");
                                      } else {
                                      Console.print("License invalid!");
                                      }
                                      } else {
                                      Console.print("Server connection error! Status: " + status);
                                      }
                                      });

                                      1. Error Handling
                                        When the server encounters an issue, it will return an error status and a detailed message, such as:
                                      • 400: Invalid data.
                                      • 500: Server error.
                                      1 Reply Last reply Reply Quote 0
                                      • d.healeyD
                                        d.healey
                                        last edited by

                                        This looks like ChatGPT output? Do you have a link to the original documentation?

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

                                        G 1 Reply Last reply Reply Quote 0
                                        • G
                                          guangcoder @d.healey
                                          last edited by guangcoder

                                          @d-healey That's right :)), I learn from anywhere, collect information and test, so i haven't got official document, just have the form of method, so contents need create and learn from professional users. For Hise coding, i learn a lot from you!

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

                                            @guangcoder said in Help me understand Server.callWithPOST:

                                            @d-healey That's right :)), I learn from anywhere, collect information and test, so i haven't got official document, just have the form of method, so contents need create and learn from professional users. For Hise coding, i learn a lot from you!

                                            Do you even have the required server-side code installed on your server?

                                            HISE Development for hire.
                                            www.channelrobot.com

                                            G 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            20

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.4k

                                            Posts