我有以下通过开放 API 生成的 Ballerina 客户端。在那里,它有一个具有以下定义的类型。
现在,当我执行程序时,在运行时出现以下错误。
error: Payload binding failed: 'map<json>' value cannot be converted to 'choreo_marketplace.devportal:API':
field 'keyManagers' in record 'choreo_marketplace.devportal:API' should be of type 'choreo_marketplace.devportal:record {| anydata...; |}?', found '["all"]'
at ballerina.http.2:createPayloadBindingError(http_client_payload_builder.bal:184)
ballerina.http.2:nonNilablejsonPayloadBuilder(http_client_payload_builder.bal:166)
ballerina.http.2:jsonPayloadBuilder(http_client_payload_builder.bal:140)
ballerina.http.2:performDataBinding(http_client_payload_builder.bal:42)
ballerina.http.2:processResponse(http_client_endpoint.bal:644)
ballerina.http.2.Client:processGet(http_client_endpoint.bal:286)
cause: {ballerina/lang.value}ConversionError
at ballerina.lang.value.0:fromJsonWithType(value.bal:370)
ballerina.http.2:nonNilablejsonPayloadBuilder(http_client_payload_builder.bal:165)
... 4 more
我在这里做错了什么?
当有效负载和提供的类型定义不匹配时,我们会收到此错误。在这种情况下,看起来
keyManagers
是一个数组。但我们在类型定义中拥有的是 record
。将 keyManagers
字段类型更改为 string[]
将解决该问题。