Api 400 에러 뜨는 데 이유를 알 수 있을까요?

public class MainApp {

public static void main(String[] args) throws IOException {

	 try {   
		 String apiURL = "https://kapi.kakao.com/v2/api/talk/memo/default/send";
	     URL url = new URL(apiURL);
	     String jsonStr = "{\"object_type\":\"text\",\"text\":\"텍스트영역입니다\",\"link\":{\"web_url\":\"https://developers.kakao.com\",\"mobile_web_url\":\"https://developers.kakao.com\"}}";
	     String template_object = URLDecoder.decode(jsonStr, "utf-8");
	     System.out.println(template_object);
         System.out.println(template_object.toString());

         System.out.println(URL);
         HttpURLConnection con = (HttpURLConnection)url.openConnection();
         con.setRequestMethod("POST");
         con.setRequestProperty("Accept", "application/json");
         con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
         con.setRequestProperty("Content-Length", String.valueOf(template_object.length()));
         con.setRequestProperty("Authorization","Bearer {token}");
         con.setDoOutput(true);
         BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
         bw.write(template_object.toString());
         bw.flush();
         bw.close();

         
         int responseCode = con.getResponseCode();
         System.out.println(con.getResponseMessage());
         System.out.println(responseCode);
         


     } catch (Exception e) {
            
         e.printStackTrace();
        
     } 

}

}

1개의 좋아요

String jsonStr = “template_object={“object_type”:“text”,“text”:“텍스트영역입니다”,“link”:{“web_url”:“https://developers.kakao.com”,“mobile_web_url”:“https://developers.kakao.com”}}”;

을 사용해주니 되네요 감사합니다.