How to put graphql Query into the Unirest request body when you change it to Code snippet using Unirest

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question:
How to put graphql Query into the Unirest request body when you change it to Code snippet using Unirest.

  1. How to parse special character?
  2. How to handle escaping characters?

Details (like screenshots):

[ My mutation query ]

mutation {
    create_item (board_id: ${boardId}, group_id: "topics", item_name: "금액 문의", column_values: "{\"___9\" : \"business.BOARD.contents(문의 내용)\", \"date4\" : \"business.BOARD.crt_date(문의일시)\", \"___\" : \"business.USER.name(사용자 이름)\", \"___8\" : \"business.BOARD.user_id(문의자 아이디)\", \"____\" : \"business.BOARD.call_no(문의자 핸드폰번호)\", \"___2\" : \"business.BOARD.email(문의자 이메일)\", \"___5\" : \"business.BOARD.company_name(문의자 회사명)\", \"__\" : \"business.BOARD.Attach_id(문의내용 첨부파일)\"}") {
        id
    }
}

[ Code snippet - Java(Unirest) ]

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.monday.com/v2")
  .header("Content-Type", "application/json")
.body("{\"query\":\"mutation {\\n    create_item (board_id: ${boardId}, group_id: \\\"topics\\\", item_name: \\\"금액 문의\\\", column_values: \\\"{\\\\\\\"___9\\\\\\\" : \\\\\\\"business.BOARD.contents(문의 내용)\\\\\\\", \\\\\\\"date4\\\\\\\" : \\\\\\\"business.BOARD.crt_date(문의일시)\\\\\\\", \\\\\\\"___\\\\\\\" : \\\\\\\"business.USER.name(사용자 이름)\\\\\\\", \\\\\\\"___8\\\\\\\" : \\\\\\\"business.BOARD.user_id(문의자 아이디)\\\\\\\", \\\\\\\"____\\\\\\\" : \\\\\\\"business.BOARD.call_no(문의자 핸드폰번호)\\\\\\\", \\\\\\\"___2\\\\\\\" : \\\\\\\"business.BOARD.email(문의자 이메일)\\\\\\\", \\\\\\\"___5\\\\\\\" : \\\\\\\"business.BOARD.company_name(문의자 회사명)\\\\\\\", \\\\\\\"__\\\\\\\" : \\\\\\\"business.BOARD.Attach_id(문의내용 첨부파일)\\\\\\\"}\\\") {\\n        id\\n    }\\n}\",\"variables\":{}}")
  .asString();

How I found the problem:
I had a question while using the API of monday.com .