【发布时间】:2016-07-23 00:01:17
【问题描述】:
说 2 条消息之一时总是出错。
{"message":"Required field 'specList' is not specified"} 或者如果我添加 specList 那么它会说 '400 Bad Request' response: {"message":"Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token"}
这就是我所拥有的:
$client = new GuzzleHttp\Client(['base_uri' => 'https://someURL/PrismGateway/services/rest/v1/']);
$res = $client->request('POST', 'vms/'.$vmId.'/clone',
[
'verify' => false,
'auth' => ['user', 'pass'],
'json' => [
'specList' => '[{"name":"test9"}]'
//tried 'create.dto.acropolis.VMCloneDTO' => '{"specList":[{"name":"test9"}]}'
]
]
);
如果我使用create.dto.acropolis.VMCloneDTO,它会告诉{"message":"Required field 'specList' is not specified"},如果我将其更改为specList,它会给我上面的反序列化错误。我不确定我做错了什么,但 api 中的实际参数被列为 create.dto.acropolis.VMCreateDTO 并且它期望 specList 响应作为 json 数据类型。
有人帮我弄清楚为什么它不起作用?
【问题讨论】: