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
Joseph 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 Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

478 views 1 15
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot