Trying to make a post.json a wiki

AI-generated summary

Seb is trying to use a Bash script to create a post via the Discourse API and make it editable by anyone (i.e., turn it into a wiki post). Initially, they shared a basic curl command to post content but were unsure how to set the wiki flag. Falco suggested reverse-engineering the API using a guide. Seb later shared screenshots of their network inspection and attempted to update the post via PUT to /posts/{id}/wiki, but the syntax was incorrect — using -d '{wiki="true"}' instead of form-data. In their final post Seb, they shared the working solution: after creating the post, they extract the post_id and send a PUT request to /posts/{id}/wiki using -F wiki=true along with the API credentials, successfully converting the post into a wiki. The key fix was using form-data (-F) instead of raw JSON (-d) for the wiki flag.

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:

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