Forum Discussion

jaread83's avatar
jaread83
Champion
7 years ago

Post a new topic to a specific board via API

Hi all,

Is it possible to post a new topic with a subject and body content into a specific board via the API? I would like the user who initialises the api call to be the author of the new topic too. I am having trouble finding anything other than viewing or editting existing content.

Cheers,

Jack

  • VikasB's avatar
    VikasB
    7 years ago

    HI jaread83

    It works perfectly except one thing that endpoint superuserescalationcode trying to return ${addPost} which is not feasible.  Either you have to create a custom response as you created in superuserescalation endpoint or you have to return ${addPost.message.root} or you can remove this freemarker variable.

     

    I think you are trying to return the status of addPost call???

    If yes, you can use ajax call with error/success methods to call the endpoint as below.  

     

     

    $.ajax({
    	url: '/aptgm87544/plugins/custom/plusnetplc/plusnetplc/superuserescalationencode',
    	error: function(error) {
    		console.log('error in call', error.responseText)
    	},
    	success: function(responseText) {
    		console.log(responseText)
       },
       type: 'GET',
    data: {subject: messagesubject,body: messagebody} });

    Hope it would resolve it.