spring - 为什么我得到异常 - 没有足够的变量可用于在 Spring Rest URI 调用中扩展?
问题描述
我正在处理与付款相关的休息 API 调用。但我遇到了一个例外。我知道这是由于将参数设置为 rest uri。
String uri = "https://test-gateway.mastercard.com/api/rest/version/52/merchant/{merchantId}/order/{orderId}/transaction/{transactionId}";
LinkedMultiValueMap<String, String> uriVars = new LinkedMultiValueMap<>();
uriVars.add("merchantId", _paymentInstrument.getAcquirerMid());
uriVars.add("orderId", _paymentInstrument.getOrderId().toString());
uriVars.add("transactionId", _paymentInstrument.getTargetTransactionId().toString());
String uri = UriComponentsBuilder.fromHttpUrl(url)
.queryParams(uriVars).build().toUriString();
VoidRequest voidRequest =
createVoidRequest(_paymentInstrument.getTargetTransactionId());
HttpEntity<VoidRequest> requestEntity = new HttpEntity<>(voidRequest, headers);
ResponseEntity<TransactionResponse> responseEntity = restTemplate.exchange(uri, HttpMethod.PUT, requestEntity, TransactionResponse.class);
我得到的异常是在 Spring 中使用 RestTemplate。异常 - 没有足够的变量可用于扩展“merchantId”。
解决方案
推荐阅读
- asp.net-mvc - 使用 _LoginPartial 和 .NET MVC 的动态导航栏
- python - Python Pandas - 非连续时间序列?
- jquery - autocomplete() 生成非文本输出
- flutter - 是否有标准/通常的数据存储位置?
- angular - 在 Angular 的选项卡式模式中正确路由
- c# - 如何编写递归函数
- android - 为 Fused Location 提供程序 onLocationChanged 设置计时器
- python-3.x - 如何获得离集群中心最近的N个数据点?
- sql-server - 查询本地日期和相对日期时间的数据类型
- html - 如何对齐下拉列表中两个单词之间的缩进空间?