Description
_
- 产品和接口: SAS(云安全中心态势感知) SDK version:1.1.1 DescribePropertySoftwareDetail 接口
- 平台:任意平台
- 最小代码:
由 OpenAPI Explorer自动生成
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util.*;
import com.aliyuncs.sas.model.v20181203.*;
public class DescribePropertySoftwareDetail {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
DescribePropertySoftwareDetailRequest request = new DescribePropertySoftwareDetailRequest();
request.setRegionId("cn-hangzhou");
request.setRemark("xxx");
request.setName("docker");
try {
DescribePropertySoftwareDetailResponse response = client.getAcsResponse(request);
System.out.println(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
System.out.println("ErrCode:" + e.getErrCode());
System.out.println("ErrMsg:" + e.getErrMsg());
System.out.println("RequestId:" + e.getRequestId());
}
}
}
报错如下:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2020-06-30T13:24Z"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Long.parseLong(Long.java:692)
at java.base/java.lang.Long.valueOf(Long.java:1144)
at com.aliyuncs.transform.UnmarshallerContext.longValue(UnmarshallerContext.java:31)
at com.aliyuncs.sas.transform.v20181203.DescribePropertySoftwareDetailResponseUnmarshaller.unmarshall(DescribePropertySoftwareDetailResponseUnmarshaller.java:46)
at com.aliyuncs.sas.model.v20181203.DescribePropertySoftwareDetailResponse.getInstance(DescribePropertySoftwareDetailResponse.java:226)
at com.aliyuncs.sas.model.v20181203.DescribePropertySoftwareDetailResponse.getInstance(DescribePropertySoftwareDetailResponse.java:26)
at com.aliyuncs.DefaultAcsClient.readResponse(DefaultAcsClient.java:364)
at com.aliyuncs.DefaultAcsClient.parseAcsResponse(DefaultAcsClient.java:201)
at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:117)
at com.company.Main.main(Main.java:151)_
经查看 SDK com.aliyuncs.sas.model.v20181203 DescribePropertySoftwareDetailResponse 类定义
public static class PropertySoftware {
private String name;
private String path;
private String instanceName;
private String ip;
**private Long create;**
private Long createTimestamp;
private String installTime;
private String version;
private String uuid;
private String instanceId;
private String intranetIp;
private String internetIp;
其中 create 为 Long,但通过 OpenAPI Explorer 测试结果来看返回的数据如下
"Propertys": [
{
"Path": "/etc/docker",
"InstanceName": "数据脱敏",
"Uuid": "数据脱敏",
"InternetIp": "",
"InstallTime": "2019-08-30 04:00:54",
"Version": "1.13.1",
"InstanceId": "数据脱敏",
"Create": "2020-06-30T13:24Z",
"Ip": "数据脱敏",
"CreateTimestamp": 1593494653000,
"IntranetIp": "数据脱敏",
"Name": "docker"
},
可以看到 Create 返回的是一个字符串形式的UTC时间,导致 DescribePropertySoftwareDetailResponse 数据类型转换出错。