Comments (3)
service is not registered error 해결 참조
https://sundries-in-myidea.tistory.com/59
heowc/programming-study#66
https://www.nanumtip.com/qa/41688/
https://velog.io/@cco2416/%EC%A1%B8%EC%97%85%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8%EA%B3%B5%EA%B3%B5%EB%8D%B0%EC%9D%B4%ED%84%B0-%ED%8F%AC%ED%84%B8-service-key-is-not-registered-error-%ED%95%B4%EA%B2%B0-%EB%B0%A9%EB%B2%95
문자열 인코딩 디코딩 참조
https://needneo.tistory.com/65
from bulletin.
두번 낚였다. 사실 내 키는 "/"가 포함된 인코딩 대상자였고 UriComponentsBuilder는 기본적으로 인코딩을 안해서 .encode()를 넣어줘야 했다. 거의 장르 아침드라마
https://support.microsoft.com/ko-kr/topic/%ED%8A%B9%EC%A0%95-%ED%8A%B9%EC%88%98-%EB%AC%B8%EC%9E%90%EB%8A%94-%EC%A3%BC%EC%86%8C-%ED%91%9C%EC%8B%9C%EC%A4%84%EC%97%90-%EC%9E%85%EB%A0%A5%EB%90%9C-url%EC%97%90%EC%84%9C-%ED%97%88%EC%9A%A9%EB%90%98%EC%A7%80-internet-explorer-a8e2a966-19d6-27af-06cc-e720f25e8b02
from bulletin.
public PostsSaveRequestDto getPostInOutsidePostApifake(String name) throws IOException, ParseException {
StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1390802/AgriFood/FdImage/getKoreanFoodFdImageList"); /*URL*/
urlBuilder.append("?" + URLEncoder.encode("serviceKey", "UTF-8") + "=csd/9isLnOcfaTZ9sdpArdEmVSBmX2L2Ml2Upn348u0yPkPYDAqp/LkA1zWCvUKMk8/1CZIiPuDhKxvp/JmuCw=");
/*Service Key*/
urlBuilder.append("&" + URLEncoder.encode("service_Type", "UTF-8") + "=" + URLEncoder.encode("json", "UTF-8")); /*xml 과 json 형식 지원*/
urlBuilder.append("&" + URLEncoder.encode("Page_No", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8")); /*페이지 번호*/
urlBuilder.append("&" + URLEncoder.encode("Page_Size", "UTF-8") + "=" + URLEncoder.encode("2", "UTF-8")); /*한 페이지 결과 수*/
urlBuilder.append("&" + URLEncoder.encode("food_Name", "UTF-8") + "=" + URLEncoder.encode("콩", "UTF-8")); /*음식 명 (검색어 입력값 포함 검색)*/
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<HttpHeaders> entity = new HttpEntity<>(headers);
ResponseEntity<String> resp = restTemplate.exchange(URI.create(urlBuilder.toString()), HttpMethod.GET, entity, String.class);
String givenData = resp.getBody();
System.out.println("givenData = " + givenData);
JSONParser jsonParser = new JSONParser();
PostsSaveRequestDto givenPost = json2XService.json2PostsSaveRequestDto(givenData);
return givenPost;
}
public PostsSaveRequestDto getPostInOutsidePostApifake2(String name) throws IOException, ParseException, URISyntaxException {
StringBuilder urlBuilder = new StringBuilder("http://apis.data.go.kr/1390802/AgriFood/FdImage/getKoreanFoodFdImageList"); /*URL*/
urlBuilder.append("?" + URLEncoder.encode("serviceKey", "UTF-8") + "=csd/9isLnOcfaTZ9sdpArdEmVSBmX2L2Ml2Upn348u0yPkPYDAqp/LkA1zWCvUKMk8/1CZIiPuDhKxvp/JmuCw=");
/*Service Key*/
urlBuilder.append("&" + URLEncoder.encode("service_Type", "UTF-8") + "=" + URLEncoder.encode("json", "UTF-8")); /*xml 과 json 형식 지원*/
urlBuilder.append("&" + URLEncoder.encode("Page_No", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8")); /*페이지 번호*/
urlBuilder.append("&" + URLEncoder.encode("Page_Size", "UTF-8") + "=" + URLEncoder.encode("2", "UTF-8")); /*한 페이지 결과 수*/
urlBuilder.append("&" + URLEncoder.encode("food_Name", "UTF-8") + "=" + URLEncoder.encode("콩", "UTF-8")); /*음식 명 (검색어 입력값 포함 검색)*/
URI uri = new URI(urlBuilder.toString());
System.out.println("uri.toString() = " + uri.toString());
RequestEntity request = RequestEntity
.get(uri)
.header("Content-type", "application/json")
.build();
ResponseEntity<String> givenData = restTemplate.exchange(request, String.class);
JSONParser jsonParser = new JSONParser();
PostsSaveRequestDto givenPost = json2XService.json2PostsSaveRequestDto(givenData.getBody());
return givenPost;
}
public PostsSaveRequestDto getPostInOutsidePostApi(String name) throws IOException, ParseException, URISyntaxException {
URI uri = UriComponentsBuilder
.fromUriString("http://apis.data.go.kr/1390802/AgriFood/FdImage/getKoreanFoodFdImageList")
.queryParam("serviceKey", "csd/9isLnOcfaTZ9sdpArdEmVSBmX2L2Ml2Upn348u0yPkPYDAqp/LkA1zWCvUKMk8/1CZIiPuDhKxvp/JmuCw=")
.queryParam("service_Type", "json")
.queryParam("Page_No", "1")
.queryParam("Page_Size", "2")
.queryParam("food_Name", name)
.build()
.encode(StandardCharsets.UTF_8)
.toUri();
RequestEntity request = RequestEntity
.get(uri)
.header("Content-type", "application/json")
.build();
ResponseEntity<String> givenData = restTemplate.exchange(request, String.class);
JSONParser jsonParser = new JSONParser();
PostsSaveRequestDto givenPost = json2XService.json2PostsSaveRequestDto(givenData.getBody());
return givenPost;
}
from bulletin.
Related Issues (20)
- parser 분리
- json simple import gradle 못찾음
- open api 사용법 학습
- json simple 라이브러리로 json <-> obj, parser, jsonarray 학습
- resTemplate 학습, URLConnection 학습
- com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
- 스프링 예외처리 학습
- 함수 예외처리 하기 HOT 1
- 함수별 인아웃풋, 기능 각주 달기
- 멘토링 받은 내용 정리 HOT 1
- 시퀀스 다이어그램 그리면서 에러 핸들링 추 가 HOT 3
- 로그 분리하기
- 에러 핸들링 상황 엑셀에 명세
- imtranslator 설치
- jpa 동작 원리 학습
- 블로그 포스팅 작성 HOT 5
- 라이브러리 작성법 학습
- 인스타그램 기획서 작성(서비스 + 운영)
- 인스타그램 시퀀스 다이어그램 작성(서비스 + 운영)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bulletin.