I posted a topic to a Flow board using the action=flow&submodule=new-topic web API module, resulting in the following post: https://test.wikipedia.org/wiki/Topic:S7xiyvpkn2y1s1t9.
The following Python code is part of a test script for a bot I'm writing, and posts a new topic to the specified Flow board:
def postflow(page, topic, message, site):
"""testing posting a new Flow topic through the API"""
token = site.get_token('csrf')
cooptitle = 'Wikipedia:Co-op/Mentorship match'
kwargs = {'action': 'flow',
'page': cooptitle,
'submodule': 'new-topic',
'token': token,
'nttopic': topic,
'ntcontent': message,
'workflow': 's7hjfbzj7bjwke99'}
query2 = site.api(**kwargs)
return query2Calling this in the Python interpreter, as:
>>> flowpost2 = mbapi.postflow('page', 'test topic', 'test message', site)
>>> pprint.pprint(flowpost2)yields the following result: https://gist.github.com/fhocutt/62f7b05c3f4e1e2f0dac
My bot needs to log the timestamp and post or topic ID of the topics it posts. I was expecting to find some portion of the API result that was more like the response to action=edit, which returns the newrevid and the newtimestamp, so:
{u'contentmodel': u'wikitext',
u'newrevid': 219714,
u'newtimestamp': u'2014-12-14T05:32:09Z',
u'oldrevid': 218886,
u'pageid': 68971,
u'result': u'Success',
u'title': u'Sandbox'}The documentation at https://www.mediawiki.org/wiki/Extension:Flow/API also suggests that the result should include values for created-topic-id and created-post-id:
<?xml version="1.0"?><api>
<flow>
<new-topic status="ok">
<result>
<topiclist created-topic-id="rwwggvyb8pz4w54x" created-post-id="rwwggvyfx3a2wpa9" />
</result>
</new-topic>
</flow>
</api>Instead, the ID and timestamp (along with a lot of other information) are provided for every single topic on the page, and I can't find any way to identify which one is the just-posted topic besides comparing the timestamps for all the topics to find the most recent one.
Could the API result for submodule=new-topic requests include some easy way to find details about the topic created?