Spring MVC - Calling a rest service from inside another rest service

前端 未结 2 439
失恋的感觉
失恋的感觉 2021-02-06 14:48

I\'m currently having a really weird issue with calling one REST service from inside another one and I could really use a hand in working out what I\'m doing wrong.

2条回答
  •  感情败类
    2021-02-06 15:42

    A HTTP415 means Unsupported Media Type. What that means is that isUsernameAvailable expects input in JSON format, but that isn't what it is getting.

    Try explicitly adding Content-Type: application/json header to your HTTP request by doing the following:

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    
    HttpEntity entity = new HttpEntity(requestJson,headers);
    restTemplate.put(uRL, entity);
    

提交回复
热议问题