Trying to make a post.json a wiki

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:

#!/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 but no luck ;p

Check this guide:

2 Likes

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

and in the Body there was

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"}'\

Solved:
Script:

  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
1 Like