# Is there a way to post as an arbitrary user when creating a new post/topic using the Discourse API?

**URL:** <https://meta.discourse.org/t/is-there-a-way-to-post-as-an-arbitrary-user-when-creating-a-new-post-topic-using-the-discourse-api/61477>\
**Category:** Product Support\
**Created:** [2017 年4 月 24 日 00:25 UTC](https://meta.discourse.org/t/is-there-a-way-to-post-as-an-arbitrary-user-when-creating-a-new-post-topic-using-the-discourse-api/61477 "2017-04-24T00:25:14Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

作者： ![john-lynch](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/john-lynch/32/81514_2.png) [@john-lynch](https://meta.discourse.org/u/john-lynch)\
发布日期： [2017 年5 月 11 日 03:17 UTC](https://meta.discourse.org/t/is-there-a-way-to-post-as-an-arbitrary-user-when-creating-a-new-post-topic-using-the-discourse-api/61477/9 "2017-05-11T03:17:25Z")

</div>

I spent some time trying to debug this issue this evening, and I made some progress:

1. I still get 403 Forbidden errors when I attempt to POST a JSON payload as string content with api\_key and api\_username in the header. I’m sure I’m simply not doing something correct here on my application’s side. I’m new to this whole web thing. 😉
2. However, I did discover why I was getting 403 Forbidden when sticking the payload directly in the URL (as above): the category I was attempting to post a new topic to had its permissions set to admins group only, and the user I was attempting to post as was not an admin. When I set that category up, I made it admin only so that I could do API testing in an isolated place; it didn’t occur to me that this would prevent me from posting as non-admins in that category using the API. Once I gave the user I was attempting to post as permission to create in that category, it worked right away. I think the whole CSRF token message in the logs was a red herring. The answer just came to me out of the blue; my debugging efforts didn’t really net me much.

So yeah: you get 403 Forbidden when attempting to post in a category as a user that doesn’t have permission to post in that category. Shocking! I guess part of me was thinking that by using the API key, I was basically overriding things like this. Apparently not. So this turns out to be almost entirely user error and I apologize for wasting people’s time. It would be nice if the logs were more clear about _why_ a POST failed (or maybe they would be if I knew how to adjust Rails’ log level, but I don’t). Thanks for being patient with me!

---

_[View the full topic](https://meta.discourse.org/t/is-there-a-way-to-post-as-an-arbitrary-user-when-creating-a-new-post-topic-using-the-discourse-api/61477)._
