# Trying to make a post.json a wiki

**URL:** https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757
**Category:** Support
**Created:** [June 7, 2019, 7:43pm UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757 "2019-06-07T19:43:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Seb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seb/32/134898_2.png) [@Seb](https://meta.discourse.org/u/Seb)
#### Post date: [June 7, 2019, 7:43pm UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/1 "2019-06-07T19:43:15Z")

</div>

Hi i am using Bash to make post in specific topics.  
I was wondering if there was a way to use the api to allow anyone to edit the post?

Here is the bash command:

```plaintext
#!/bin/bash

  curl -k -X POST https://discourse.org/posts.json \
  -H "Content-Type: multipart/form-data;" \
  -F api_key="234234sdfsdf" \
  -F api_username="hubot" \
  -F topic_id="46605" \
  -F raw="Wiki_test_"

```

I have been trying to figure it out using the [API documentations](https://docs.discourse.org/#) but no luck ;p

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [June 7, 2019, 7:46pm UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/2 "2019-06-07T19:46:17Z")

</div>

Check this guide:

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

---

<div class="post-metadata">

### Author: ![Seb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seb/32/134898_2.png) [@Seb](https://meta.discourse.org/u/Seb)
#### Post date: [June 7, 2019, 8:42pm UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/3 "2019-06-07T20:42:56Z")

</div>

I think i am closer to being able to make the post i made a wiki but i still cant resole the issue.

When i reverse engeneered my command i got

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

and in the Body there was

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/7/e7b6aec0b9911bac2fe8d58d7cf7aea7a53db091.png)

Here is the Bash script that attempts this but i cant get it to work:

```
#!/bin/bash

  response="$(curl -k -X POST https://discourse.org/posts.json
-H “Content-Type: multipart/form-data;”
-F api_key=“234234sdfsdf”
-F api_username=“hubot”
-F topic_id=“46605”
-F raw=“Wiki_test_”")"

post_id="$(echo "$response" | grep -oP '"id":\K.*(?=,"name":)')"
echo "post_id= "$post_id

curl -k -X PUT https://discourse.org/posts/$post_id/wiki \
-H "Content-Type:multipart/form-data;" \
-d '{wiki="true"}'\

```

---

<div class="post-metadata">

### Author: ![Seb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seb/32/134898_2.png) [@Seb](https://meta.discourse.org/u/Seb)
#### Post date: [June 10, 2019, 7:45pm UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/4 "2019-06-10T19:45:17Z")

</div>

Solved:  
Script:

```plaintext
  response="$(curl -k -X POST https://discourse.org/posts.json
-H “Content-Type: multipart/form-data;”
-F api_key=“234234sdfsdf”
-F api_username=“hubot”
-F topic_id=“46605”
-F raw=“Wiki_test_”")"

post_id="$(echo "$response" | grep -oP '"id":\K.*(?=,"name":)')"
echo "post_id= "$post_id

curl -k -X PUT https://discourse.org/posts/$post_id/wiki \
 -H "Content-Type:multipart/form-data;" \
 -F api_key=$API_KEY \
 -F api_username=$API_USERNAME \
 -F wiki=true

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 12, 2022, 6:53am UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/5 "2022-11-12T06:53:39Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [November 12, 2022, 8:15am UTC](https://meta.discourse.org/t/trying-to-make-a-post-json-a-wiki/119757/6 "2022-11-12T08:15:09Z")

</div>


