# API를 통해 새 주제 게시 시 422 오류 발생

**URL:** https://meta.discourse.org/t/422-error-when-posting-new-topic-via-api/173644
**Category:** Development
**Tags:** rest-api
**Created:** [12월 17, 2020, 8:30오후 UTC](https://meta.discourse.org/t/422-error-when-posting-new-topic-via-api/173644 "2020-12-17T20:30:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![John\_Streeter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/john_streeter/32/200437_2.png) [@John\_Streeter](https://meta.discourse.org/u/John_Streeter)
#### Post date: [12월 17, 2020, 8:30오후 UTC](https://meta.discourse.org/t/422-error-when-posting-new-topic-via-api/173644/1 "2020-12-17T20:30:00Z")

</div>

여러분 안녕하세요. API를 통해 새 주제를 게시하려고 하는데, 폼 대신 일반 텍스트를 사용할 때마다 아래 메시지와 함께 422 오류가 계속 발생합니다:

```plaintext
        " **action**": "create_post",
        " **errors***":[
        "Title can't be blank",
        "Title is too short (minimum is 5 characters)",
        "Title seems unclear, most of the words contain the same letters over and over?",
        "Category can't be blank"

```

본문(body)은 다음과 같습니다:

```plaintext
    {
    "title": "Cannot Add Custom Rate for Retainer Rate",
    "raw":"hi",
    category":22,
    "displayusername": "nickclark",
    "created_at":"2020-12-17"
    }

```

content-type = multipart/form-data를 사용하고 있는데, 이것이 문제일까요? 무엇을 사용해야 하나요?

도움 주셔서 감사합니다!

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [12월 17, 2020, 11:23오후 UTC](https://meta.discourse.org/t/422-error-when-posting-new-topic-via-api/173644/2 "2020-12-17T23:23:48Z")

</div>

API를 사용하면서 “Title can’t be blank”(제목은 비워둘 수 없습니다)와 같은 오류가 발생하는데, 실제로 제목을 전달하고 있는 것처럼 보인다면, 이는 보통 데이터가 API에 올바른 형식으로 전송되지 않아 API가 전송된 데이터를 읽을 수 없는 경우입니다. form-data 대신 JSON을 보내고 있지는 않나요?

토픽을 생성하기 위한 curl 요청 예시는 다음과 같습니다:

```plaintext
curl -i -sS -X POST "http://localhost:3000/posts.json" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 079fb2bb12d3b436bb11bde8eb58aaa9a36560fa7d79b14b3087aa40b1ebc2c4" \
-H "Api-Username: blake.erickson" \
-F "title=94214157b89 b723d7bc93f f40ec06495c" \
-F "raw=e65c9465ca693efc7b676ce4d236a6a6 1978ce887069fd2b3dbd67422f151823 fcb471fe25bae2d9f2889de60edbd06b"

HTTP/1.1 200 OK

```
