示例

请求示例

// https://github.com/aliyun/iotx-api-gateway-client

IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的");

ioTApiClientBuilderParams.setAppSecret("你的");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID

String uuid = UUID.randomUUID().toString();

String id = uuid.replace("-", "");

request.setId(id);

// 设置API版本号

request.setApiVer("1.0.1");

// 设置参数

request.putParam("serviceType", "value0");

request.putParam("needResVerify", value1");

request.putParam("name", value2");

request.putParam("securityInfo", value3");

request.putParam("description", value4");

request.putParam("serviceId", value5");

request.putParam("reqProtocol", value6");

request.putParam("uri", value7");

request.putParam("needReqSign", value8");

request.putParam("properties", value9");

request.putParam("appId", value10");

// 如果需要,设置headers

Map headers = new HashMap(8);

// headers.put("你的");

// 设置请求参数域名, path, request, isHttps, headers

ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/industry/notification/callback/update", request, true, headers);

System.out.println(

"response code = " + response.getCode()

+ " response = " + new String(response.getBody(), "UTF-8")

+ " headers = " + response.getHeaders().toString()

);

正常返回示例

JSON 格式

{

"id": "997bb515-6b1f-4c09-a873-cb08f3cf68d2",

"code": 200,

"message": null,

"localizedMsg": null

}

异常返回示例

JSON 格式

{

"id": "f149f51a-c28c-46b1-b8e7-5e12ffd2db1e",

"code": 20600,

"message": "check uri ssrf failed",

"localizedMsg": "check uri ssrf failed"

}

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐