Connecting with Rest API
Last updated
Last updated
This documentation explains how to connect to Chochae Engine REST API using a POST request with a JSON payload. The example uses a specific endpoint and includes the necessary headers and body data.
Webhook API
Method: POST
URL: https://ccgpt-uat.iapp.co.th/common/webhook-api?id=YOUR_ID
Name | Type | Description |
---|---|---|
The request body is in JSON format. In this example, it contains a message in Thai.
First, import the Axios library to make HTTP requests:
Define the data to be sent in the POST request as a JSON string. In this example, the payload contains a message in Thai:
Set up the Axios request configuration, including the HTTP method, URL, headers, and data payload:
method: HTTP method for the request (POST in this case).
maxBodyLength: Configures Axios to handle large payloads.
url: Endpoint to which the request is sent.
headers: HTTP headers for the request, specifying the content type as application/json
.
data: JSON payload to be sent.
Use axios.request
to send the configured request. Handle the response and potential errors with then
and catch
blocks:
.then((response) => { ... }): Executes if the request is successful, logging the response data.
.catch((error) => { ... }): Executes if there is an error during the request, logging the error.
If the request is successful, you might receive a response similar to the following:
for the video tutorial please click : https://ccgpt-uat.iapp.co.th/public/video/api.mp4
Content-Type
String
Specifies the media type of the resource. Set to application/json