
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
제 ARC가 강의랑은 너무 달라서 코드스니펫에 있는 "만약 안되면 이 코드를 사용하세요" 를 그대로 복붙했는데요, HttpStatus에 빨간줄이 뜨고 다음과 같은 옵션을 주는데 어떤걸 해야하나 해서요...
 11.47.48 p. m..png)
작성한 코드 및 에러 메세지
package com.sparta.week04.utils;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
public class NaverShopSearch {
public String search() {
RestTemplate rest = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("X-Naver-Client-Id", "NZDnbd0Ak7mzXrsEroB8");
headers.add("X-Naver-Client-Secret", "KZHfzXjtN_");
String body = "";
HttpEntity<String> requestEntity = new HttpEntity<String>(body, headers);
ResponseEntity<String> responseEntity = rest.exchange("https://openapi.naver.com/v1/search/shop.json?query=adidas", HttpMethod.GET, requestEntity, String.class);
HttpStatus httpStatus = responseEntity.getStatusCode();
int status = httpStatus.value();
String response = responseEntity.getBody();
System.out.println("Response status: " + status);
System.out.println(response);
return response;
}
public static void main(String[] args) {
NaverShopSearch naverShopSearch = new NaverShopSearch();
naverShopSearch.search();
}
}
