curl
Scenarios
To use the curl command to call an API through App authentication, download the JavaScript SDK to generate the curl command, and copy the command to the CLI to call the API.
Prerequisites
You have obtained the domain name, request URL, and request method of the API to be called, and the AppKey and AppSecret of the App for calling the API. For more information, see Preparation.
API Calling Example
- Use the JavaScript SDK to generate the curl command.
Download the JavaScript SDK and decompress it. Open demo.html in a browser. The following figure shows the demo page.

- Specify the key, secret, method, protocol, domain name, and URL. For example:
1 2 3 4
Key=4f5f626b-073f-402f-a1e0-e52171c6100c Secret=****** Method=POST Url=https://{apig-endpoint}serviceEndpoint
- Specify query and header parameters in JSON format, and set the request body. The ID of the accessed API is required. You need to enter the specific ID information. The x-api-id parameter is used in Headers.
- Click Send request to generate a curl command.
$ curl -X POST "https://{apig-endpoint}serviceEndpoint/" -H "X-Sdk-Date: 20180530T115847Z" -H "Authorization: SDK-HMAC-SHA256 Access=071fe245-9cf6-4d75-822d-c29945a1e06a, SignedHeaders=host;x-sdk-date, Signature=9e5314bd156d517******dd3e5765fdde4" -d "" - Then, add the x-Authorization header to the command. The value of x-Authorization header is the same as that of the Authorization header. Copy the curl command to the CLI to access the API.
$ curl -X POST "https://{apig-endpoint}serviceEndpoint/" -H "X-Sdk-Date: 20180530T115847Z" -H "Authorization: SDK-HMAC-SHA256 Access=071fe245-9cf6-4d75-822d-c29945a1e06a, SignedHeaders=host;x-sdk-date, Signature=9e5314bd156d517******dd3e5765fdde4" -H "X-Authorization: SDK-HMAC-SHA256 Access=071fe245-9cf6-4d75-822d-c29945a1e06a, SignedHeaders=host;x-sdk-date, Signature=9e5314bd156d517******dd3e5765fdde4" -d "" Congratulations, sdk demo is running
Last Article: Android
Next Article: Other Programming Languages
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.