The following sample code shows how to sign a request and use an HTTP client to send an HTTPS request: Sample code is divided into three categories to demonstrate request signing and HTTP request sending.
- AccessService: indicates the abstract category that converts the GET, POST, PUT, and DELETE methods into the access method.
- Demo: indicates the execution entry used to simulate GET, POST, PUT, and DELETE request sending.
- AccessServiceImpl: indicates the implementation of the access method. Code required for API gateway communication is in the access method.
Download sample code package SdkDemo.zip from https://apig-demo.obs.eu-de.otc.t-systems.com/java/SdkDemo.zip.
Decompress the package to obtain the following files in
For details about region and serviceName in the sample code, see Regions and Endpoints.
- Parameters URI, AK, SK, and HTTP METHOD are mandatory.
- You can use request.addHeader() to add header information.