次のコードを使用してSpring RestアプリケーションでMicrosoft Flow POST URLを1つヒットしようとしていますが、401エラーが発生しています。 マイコード:承認ヘッダーで送信すると、Spring RestTemplateが401 Unauthorizedエラーを返します
@RequestMapping(value = "/hookslistner", method = RequestMethod.POST)
public ResponseEntity<Void> recieveWebhook(@RequestBody InventorySystemModel inventory,
@RequestHeader("event") String event,
@RequestHeader("Authorization") String authorization) {
// authorization = "Basic <Base64 encoded value of username:pwd>"
RestTemplate restTemplate = new RestTemplate();
org.springframework.http.HttpHeaders httpHeaders = new org.springframework.http.HttpHeaders();
String url = "https://prod-01.centralindia.logic.azure.com/workflows/835348<hiding rest of part>";
String headerName = "Authorization";
httpHeaders.add(headerName, authorization);
httpHeaders.add("Content-Type", "application/json");
HttpEntity<String> requestEntity = new HttpEntity<>("Headers", httpHeaders);
System.out.println(">>>>>>>" + restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class).getBody());
}
エラー:私のターゲットURLがhttpsであると私はlocalhostはhttpので
SEVERE: Servlet.service() for servlet [webhooks] in context with path [/inventoryhooks] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 401 Unauthorized] with root cause
org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
.
.
.
はそれですか?
誰かが間違っていると私に指摘できますか?あなたはこの問題をチェックするために
その時点で例外がスローされますが、SSL restTemplateを取得するには、次のコードスニペットを参照することができますか? RestTemplateで、またはメソッドに入る前に? –
'restTemplate.exchange' –