为什么会收到Exception-在Spring Rest URI调用中没有足够的变量可扩展?

时间:2019-06-25 15:56:45

标签: spring rest encodeuricomponent

im正在处理与付款相关的rest API。但是我遇到了一个例外。我知道这是由于将参数设置为其余的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”。

0 个答案:

没有答案