커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
HttpStatus 오류
undefined주차
북마크
김*아
댓글
2
추천
0
조회수
13
조회수
13
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


제 ARC가 강의랑은 너무 달라서 코드스니펫에 있는 "만약 안되면 이 코드를 사용하세요" 를 그대로 복붙했는데요, HttpStatus에 빨간줄이 뜨고 다음과 같은 옵션을 주는데 어떤걸 해야하나 해서요...



스파르타 즉문즉답




작성한 코드 및 에러 메세지

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();

}

}




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴