Confluence Questions has an importbounties API, but no mention of bounties in any docs

What this just a legacy of the Answers -> Questions migrations? Seems odd to build in an exposed API for internal use case.

 

https://docs.atlassian.com/confluence-questions/rest/resource_ImportResource.html#path__import_bounties.html

1 answer

1 accepted

2 votes
Accepted answer
Joe Clark Atlassian Team Jul 21, 2016

Hey Eddie,

Yes, this was built specifically for the migration of Answers to Confluence Questions. The API is undoubtedly not supported since the "Bounties" feature in Confluence Questions does not yet exist beyond the schema to persist the information.

If you want to play around with it, the expected input looks something like this (python script from the initial migration):

import json
import requests
from datetime import datetime
 
def award_bounty_request(on_question, to_user, amount, from_user, for_answer=None):
    """
    Awards a bounty to a user in Confluence. The `on_question` (ID of the related question), `to_user` (Username of the user receiving the bounty,)
    `from_user` (Username of the user sacrificing the bounty) and `amount` parameters are required.

    """
    now = datetime.now().isoformat()
    payload = {
        "questionId": on_question,
        "awarder": from_user,
        "creator": from_user,
        "awardee": to_user,
        "points": amount,
        "creationDate": now,
        "dateAwarded": now
    }

    if from_user:
        payload["awarder"] = from_user

    if for_answer:
        payload["answerId"] = for_answer

    r = s.post(confluence_url + "/rest/questions/1.0/import/bounties", headers={"Content-type": "application/json"}, data=json.dumps(payload), timeout=60)
    if r.status_code == 200:
        # Success
        return True, r.text

    return False, r.text

# Usage
award_bounty_response = award_bounty_request(on_question=karma_question_id, to_user=username, from_user=bounty_username, amount=reputation_delta)

                    if award_bounty_response[0]:
                        # Succeeded!
                        save_karma(karma_user.id)
                        karma_stats.create_one()
                        logging.debug(u"SAVE: Successfully applied %s reputation to User %s: %s <%s>" % (reputation_delta, karma_user.id, karma_user.username, karma_user.email))

                    else:
                        # Failed :-(
                        karma_stats.fail_one()
                        logging.debug(u"ERROR: Failed to apply %s reputation for User %s: %s <%s>" % (reputation_delta, karma_user.id, karma_user.username, karma_user.email))
                        logging.debug(get_reputation_response[1])

 

Hope this helps!

Thank you! Yes.  I guess the implied answer is that I could create bounties, but they would not be reflected anywhere in the UI.  It seems playing with the REST API Browser (RAB) that I can't create potential bounties (without awardee and dateAwarded) - is that true?

 

Context - we are migrating from Jive to Confluence and I wanted to use bounties to encourage unanswered questions to be answered.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 5 hours ago in Statuspage

194 years of downtime: looking back on incident data from 2018

Statuspage customers logged more than 194 years of collective incidents in 2018. That’s a whopping 87% increase from the  104 years logged in 2017 , and we aren’t even through December yet....

16 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you