Help me understand Server.callWithPOST
-
@guangcoder said in Help me understand Server.callWithPOST:
@d-healey endpoint is: "verify-license"
But what data is it expecting?
-
@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
-
@guangcoder But what data is the endpoint expecting you to send to it?
-
@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.callWithPOSTServer.callWithPOST("verify-license", payload, function(status, response) { });
payload = email & product key
-
@guangcoder Do you have some documentation for the end point you are calling that I can look at?
-
@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:
- 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.
- 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:
- 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. - 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!" }
- 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:
- 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. - 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", }
- 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!" }
- 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).
- 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);
}
});- 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.
-
This looks like ChatGPT output? Do you have a link to the original documentation?
-
@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!
-
@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?
-
@LindonAt the moments, i just test om local server, then test request by Postman, it work!```
{ "email": "abcd@outlook.com", "productKey": "abcd-1234", }
Here is the form that i tested, it responded success! However, on Hise not work, it may have some restriction with constant or I need learn more document for understanding its working method.
-
@guangcoder In HISE try writing the data directly into the payload, instead of using variables, and see if that works.
-
@d-healey Thanks Bro for suggestion, This problem may need more research. Ah, Could you please, give a instant about this constant:
Server.setBaseURL("http://hise.audio"); const var p = { "first_argument": 9000 }; // This dummy file just returns the `first_argument` as `post_argument`... Server.callWithPOST("post_test.php", p, function(status, response) { Console.print(response.post_argument); });
I read documents but not really understand! Thank you!
-
@guangcoder said in Help me understand Server.callWithPOST:
Server.setBaseURL("http://hise.audio");
This needs to be your server URL.