它总是错误地说出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数据类型。
有人能帮我弄清楚为什么它不工作吗?
发布于 2016-07-23 00:01:18
我想通了。去掉json,添加body:
'body' => '{"specList":[{"name":"test9"}]}'https://stackoverflow.com/questions/38529326
复制相似问题