문의 시, 사용하시는 개발환경과 디벨로퍼스 앱ID를 알려주세요.
개발환경 SpringBoot 2.7.3 , ID : 925073
현재 카카오 채널 친구 관계 확인 api를 개발하면서 하단과 같은 오류를 계속 확인하고 있습니다.
channel_public_ids 파라미터는 배열 형식의 JsonString을 인코딩하여 전달해야 합니다.
“…?channel_public_ids=” + URLDecoder.Encode("[\"_채널아이디\"]","utf-8")
String[] channels = new String[1];
channels[0] = URLEncoder.encode("채널 id", "UTF-8");
스프링에서 위와 같이 계속 보내고 있는데 요청이 잘 되는건 적고 거의 매번 오류가 나와서 문의드립니다.
형식과 인코딩상 문제가 없는 것 같은데 왜 계속
failed to parse parameter
이 오류가 뜨는 걸까요??
String[] channels = new String[1];
channels[0] = URLEncoder.encode("test", "UTF-8");
KakaoChannelResponseDto kakaoChannelResponseDto = null;
try{
kakaoChannelResponseDto = kakaoClient.getKakaoChannelRelationship("Bearer "+accessToken, channels);
@FeignClient(name = "kakaoclient", url = "https://kapi.kakao.com")
public interface KakaoClient {
@GetMapping(value = "/v1/user/service/terms")
KakaoTermsResponseDto getKakaoTermsWithHeader(@RequestHeader("Authorization") String authorization);
@GetMapping(value = "/v2/user/me" , consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
Map<String, Object> getKakaoUserInfoByToken(@RequestHeader("Authorization") String authorization);
@GetMapping(value = "/v1/api/talk/channels")
KakaoChannelResponseDto getKakaoChannelRelationship(@RequestHeader("Authorization")String authorization, @RequestParam(name = "channel_public_ids") String[] channels);
}
Spring OpenFeign을 사용해서 api를 통신하고 있는데 정상적으로 친구 관계 확인이 될 때가 있고 아닐때가 있어서 문의드립니다
OpenFeign으로 통신했을때 로그는 하단과 같아요
2023-07-11 13:41:50.519 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] —> GET https://kapi.kakao.com/v1/api/talk/channels?channel_public_ids=test HTTP/1.1
2023-07-11 13:41:50.519 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] Authorization: Bearer 엑세스토큰
2023-07-11 13:41:50.519 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] —> END HTTP (0-byte body)
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] <— HTTP/1.1 400 Bad Request (29ms)
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] access-control-allow-headers: Content-Type,X-Requested-With,Accept,Authorization,Origin,KA,Cache-Control,Pragma
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] access-control-allow-origin: *
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] caller-appid: 925073
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] connection: close
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] content-length: 135
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] content-type: application/json;charset=UTF-8
2023-07-11 13:41:50.549 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] date: Tue, 11 Jul 2023 04:41:51 GMT
2023-07-11 13:41:50.550 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] server: Apache
2023-07-11 13:41:50.550 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] x-request-id: 1a5f38b8-4794-48cc-996b-f5f2f44c497a
2023-07-11 13:41:50.550 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship]
2023-07-11 13:41:50.550 DEBUG 1 — [nio-8080-exec-8] c.s.i.util.openfeign.KakaoClient : [KakaoClient#getKakaoChannelRelationship] {“msg”:“failed to parse parameter. name=channel_public_ids, stringToParse=test, paramString=test, paramStringAlias=null”,“code”:-2}
channel_public_ids 값은 배열이 아닌 JSON Array 형태의 String 값이 전달되어야 합니다.
ex)
@GetMapping(value = "/v1/api/talk/channels")
KakaoChannelResponseDto getKakaoChannelRelationship(@RequestHeader("Authorization")String authorization, @RequestParam(name = "channel_public_ids") String channels);
kakaoClient.getKakaoChannelRelationship("Bearer " + ..., "[\"_test\"]");