This plugin provides 3 methods for testing REST API functionality.
RESTAPI Tester Plugin Manual
1. RESTAPI HJH Server Testing
This method tests the RESTAPI using a default server provided by the plugin.
- Create a new Blueprint in the Content Browser.
- In the Blueprint editor, search for the "RESTAPI HJH Server Testing" function when adding a node.
- Add this node to the graph and connect the execution pin.
- Input a float value as a parameter (this value is only output to the log and doesn't affect the server call).
- Compile and save the Blueprint.
- When you run the game or call the Blueprint in the editor, it will send a GET request to the default provided server (http://61.32.96.242:8000/howtotest/jjj).
Note: The default server is maintained to be available at all times, but there might be instances when it's unavailable.
2. Make REST API Call (Using a custom server)
This method allows you to test the RESTAPI with a server address of your choice.
- Create a new Blueprint in the Content Browser.
- In the Blueprint editor, search for the "Make REST API Call" function when adding a node.
- Add this node to the graph and connect the execution pin.
- Input two string parameters to the function:
- Compile and save the Blueprint.
- When you run the game or call the Blueprint in the editor, it will send a request to the specified URL using the specified HTTP method.
3. Send Message Async (Asynchronous POST request)
This method allows you to send an asynchronous POST request to a specified server and receive the response. It is compatible with Epic Games' JSON plugin on the market to convert JSON string from JSON Object.
- Create a new Blueprint in the Content Browser.
- In the Blueprint editor, search for the "Send Message Async" function when adding a node.
- Add this node to the graph and connect the execution pin.
- Input two string parameters to the function:
- BaseUrl: The base URL of the server you want to send the message to (e.g., "http://your-server.com/api")
- Message: The message you want to send
- Create a variable of type "Message Response" to store the output.
- Connect the "Out Response" pin from the "Send Message Async" node to your "Message Response" variable.
- Add a "Delay" node after the "Send Message Async" node to wait for the response (e.g., 1-2 seconds).
- After the delay, you can access the response data from your "Message Response" variable.
- Compile and save the Blueprint.
Here's an example of how your Blueprint might look
Output and Logging
All methods will output the server response to the log. In the output log, you can check the following information:
- HTTP response code
- Response content type
- Response body
- If the response is JSON, the parsed JSON fields
For the "Send Message Async" function, you can also access the response data directly in your Blueprint through the "Message Response" structure, which includes:
- Success: A boolean indicating if the request was successful
- Message: A string containing a message about the response (e.g., "JSON response received successfully")
- JsonResponse: A structure containing the parsed JSON data as key-value pairs
This plugin is useful for quickly checking the status of RESTAPI servers and sending asynchronous requests. It can be particularly helpful when testing and debugging communication with servers during game development.