Bot

메시지 전송시 JSON 내 content 키가 있으나 [ INVALID_PARAMETER ]가 발생합니다.

정하늘_AK

2024.06.28읽음 282

메시지 전송 JSON 전문 내 필수 파라미터가 모두 존재하나 자바 소스 코드 내에서 API 연동시 실패가 발생합니다.
자바 소스 코드를 통해 생성된 JSON 전문으로 POSTMAN 테스트 툴을 통해 연동할 경우 정상적으로 수행되나, INVALID_PARAMETER가 지속 발생하는 상황입니다.
혹시 제가 놓친 부분이 있는지 답변 부탁 드립니다.
response. {"code":"INVALID_PARAMETER","description":"content does not exist."}
request.
{
    "content": {
        "type": "flex",
        "altText": "오늘의 생일자를 함께 축하해주세요!",
        "contents": {
            "type": "carousel",
            "altText": null,
            "contents": [
                {
                    "type": "bubble",
                    "size": "kilo",
                    "header": null,
                    "body": {
                        "type": "box",
                        "layout": "vertical",
                        "margin": null,
                        "cornerRadius": null,
                        "borderWidth": null,
                        "borderColor": null,
                        "height": null,
                        "offsetStart": null,
                        "offsetEnd": null,
                        "width": null,
                        "backgroundColor": null,
                        "separatorColor": null,
                        "contents": [
                            {
                                "text": "오늘의 생일자를 알려드립니다.",
                                "size": "sm",
                                "color": "#146bb8",
                                "flex": 0,
                                "margin": null,
                                "wrap": false,
                                "align": "center",
                                "gravity": null,
                                "weight": "bold",
                                "type": "text",
                                "aspectMode": null
                            },
                            {
                                "type": "box",
                                "layout": "vertical",
                                "margin": "xxl",
                                "cornerRadius": "50px",
                                "borderWidth": "1px",
                                "borderColor": "#22222220",
                                "height": "60px",
                                "offsetStart": "85px",
                                "offsetEnd": "85px",
                                "width": "60px",
                                "backgroundColor": null,
                                "separatorColor": null,
                                "contents": [
                                    {
                                        "flex": 0,
                                        "size": null,
                                        "margin": "xxl",
                                        "url": "https://i.ibb.co/XxXMKxH/WORKSMOBILE.png",
                                        "align": "center",
                                        "position": null,
                                        "type": "image",
                                        "aspectMode": "cover"
                                    }
                                ],
                                "separator": false
                            },
                            {
                                "text": "네이버웍스팀",
                                "size": "sm",
                                "color": "#aaaaaa",
                                "flex": 0,
                                "margin": "lg",
                                "wrap": true,
                                "align": "center",
                                "gravity": null,
                                "weight": null,
                                "type": "text",
                                "aspectMode": null
                            },
                            {
                                "type": "button",
                                "style": "primary",
                                "action": {
                                    "type": "uri",
                                    "label": "김아무개 주임",
                                    "uri": "https://naver.com"
                                },
                                "color": "#146bb8",
                                "margin": "lg",
                                "height": "sm"
                            }
                        ],
                        "separator": false
                    },
                    "footer": null
                }
            ]
        }
    }
}

댓글1

  • 업데이트 된 답글입니다.

    Eric

    Java 로 수행하시는 거라면 아래와 같이 수행해보시기 바랍니다. 본문 내용 테스트 잘 됩니다.

    URL url = new URL(url);

           HttpURLConnection connection = (HttpURLConnection) url.openConnection();

           connection.setRequestMethod("POST");
           connection.setDoOutput(true);
           connection.setRequestProperty("Content-Type", "application/json");
           connection.setRequestProperty("Authorization", "Bearer " + bearerToken);
           
           String content = "JSON CONTENT";
           try (OutputStream os = connection.getOutputStream()) {
               byte[] input = content.getBytes("utf-8");
               os.write(input, 0, input.length);
           }

           connection.getResponseCode();

    2024.06.28

    0
이전 글SMTP로 메일 전송시 본문내용 복사되어 전송됩니다.
다음 글개발 Workflow 에 메신저를 연동하고 싶은데요.
목록

궁금한 점을 해결하지 못하셨나요?
지금 바로 NAVER WORKS 사용자들에게 물어보세요!