# Problem creating a category using the API

**URL:** https://meta.discourse.org/t/problem-creating-a-category-using-the-api/59026
**Category:** Development
**Created:** [March 13, 2017, 9:19pm UTC](https://meta.discourse.org/t/problem-creating-a-category-using-the-api/59026 "2017-03-13T21:19:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [March 13, 2017, 9:19pm UTC](https://meta.discourse.org/t/problem-creating-a-category-using-the-api/59026/1 "2017-03-13T21:19:00Z")

</div>

I have successfully created a **topic** using the API (using entry point `posts`, as described [here](http://docs.discourse.org/#tag/Topics)), which makes me think my process is good.

But when I try to create a **category** (using entry point `categories.json`, as documented [here](http://docs.discourse.org/#tag/Categories%2Fpaths%2F~1categories.json%2Fpost), or entry point `categories`, as sniffed under Chrome using [this method](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576), or even entry point `create_category`, as it seems to be used [here](https://github.com/discourse/discourse_api/blob/f0f1267072b1e5271f9450f2a647b23489b731b3/lib/discourse_api/api/categories.rb)), I get the following error:

```plaintext
Error: failed [400] <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Action Controller: Exception caught</ti
tle> <style> body { background-color: #FAFAFA; color: #333; margin: 0px; } body, p, ol, ul, td { font-family: helvetica, ve
rdana, arial, sans-serif; font-size: 13px; line-height: 18px; } pre { font-size: 11px; white-space: pre-wrap; } pre.bo
x { border: 1px solid #EEE; p

```

(followed by a dozen pages of css/html gibberish)

Any idea what I’m doing wrong?

---

<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: [March 13, 2017, 10:52pm UTC](https://meta.discourse.org/t/problem-creating-a-category-using-the-api/59026/2 "2017-03-13T22:52:24Z")

</div>

I’m not sure, can you send me your actual post request. Feel free to obfuscate your api key.

I’m able to create a category via the api with:

 ![](https://global.discourse-cdn.com/meta/original/3X/b/1/b19dd763ec4f32d942a878b7e963e42c5e6ea5fa.png)

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [March 14, 2017, 10:01am UTC](https://meta.discourse.org/t/problem-creating-a-category-using-the-api/59026/3 "2017-03-14T10:01:52Z")

</div>

Thanks @blake. You lead me to try Postman, which in turn allowed me to discover my silly mistake: I wasn’t passing the api\_key and api\_username properly. I guess it worked earlier with creating a topic because this operation doesn’t require authentication.
