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
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

143 views 0 3
Join discussion

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