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

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

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


ARC에서 복사한 코드에서 오류가 발생합니다. (http type에서 문제가 일어납니다)

코드 스니펫에서 복사한 코드도 마찬가지입니다.



스파르타 즉문즉답



작성한 코드 및 에러 메세지

package com.sparta.week04.utils;


import org.springframework.http.HttpEntity;

import org.springframework.http.HttpMethod;

import org.springframework.http.HttpStatus;

import org.springframework.http.ResponseEntity;

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", "Ag6cAR8BeSBlmG4SlDSo");

headers.add("X-Naver-Client-Secret", "9Va1MsD67l");

String body = "";


HttpEntity<String> requestEntity = new HttpEntity<String>(body, headers);

ResponseEntity<String> responseEntity = rest.exchange("https://openapi.naver.com/v1/search/shop.json?query=iphone", 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
댓글 알림
나의얼굴