簡體   English   中英

org.springframework.web.client.HttpClientErrorException:401空

[英]org.springframework.web.client.HttpClientErrorException: 401 null

我正在從一個模塊調用服務到另一個模塊。 但它拋出一個異常:

org.springframework.web.client.HttpClientErrorException:401空

對“ http:// localhost:80 .. / ... / ... Report ”的POST請求導致401(空); 調用錯誤處理程序。

我可以直接從郵遞員那里獲得這項服務。 但是,當從spring boot模塊調用它時,它將引發錯誤。

BaseResponseDTO baseResponseDTO = restTemplate.postForObject("http://localhost:80../.../...Report", requestDTO, BaseResponseDTO.class);

錯誤拋出這一行

I added authorization headers in MultiValueMap and i added object request in HttpEntity. here i added code.

MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
headers.add("Authorization", "bearer "+<TOKEN>);
HttpEntity<MyObject> httpEntityRequest = new HttpEntity<>(myObjectReference, headers);

BaseResponseDTO baseResponseDTO = restTemplate.postForObject("http://localhost:80../.../...Report", httpEntityRequest , BaseResponseDTO.class);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM