I’d like to be able to create messages that are assigned to specific users. Is this something that is possible already and I am missing something, or that you would consider adding?
I am not seeing reference to the assign plugin in the API docs. Seems to me an e.g. assigned_to=usernname should be an option.
The background to this is that I am using discourse as a ticket system, using @angus’s Tickets Plugin 🎟. The easiest way for me to allow members to create tickets is to create a gravity form in wordpress that creates the message in discourse. I know this can work and I have the rest of it lined up, just not the ability to assign tickets to specific users upon creation.
I need to create topics by API as staged users (sender does not need to have account in Discourse), so I have to do it by the /admin/email/handle_mail endpoint. But it does not return topic ID and seems to work in a batch.
What is the best way how to assign that topic?
The best for me would be if /admin/email/handle_mail endpoint could accept an assign field.
I’m ussing the Discourse Assign plugin and managed to do it, here’s the python code:
import requests
# You can get this from by reverse engineering the assign request and checking the parameters and values on the console as someone mentioned before :)
base_url = 'YOUR_URL'
endpoint = '/assign/assign'
payload = {
'username': 'USERNAME', #The username of the person you want to assign the topic to
'group_name': '',
'target_id': TOPIC_NUMBER,
'target_type': 'Topic'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'URL_OF_THE_TOPIC',
'Accept': '*/*',
'Api-Key': 'YOUR_API_KEY',
'Api-Username': 'YOUR_USERNAME'
}
response = requests.put(f"{base_url}{endpoint}", data=payload, headers=headers)
if response.status_code == 200:
print("Assignment successful!")
else:
print(f"Assignment failed with status code {response.status_code}: {response.text}")