Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:19:10+00:00 2026-05-24T20:19:10+00:00

I’ve been trying for a few days to get the BitBucket API to work

  • 0

I’ve been trying for a few days to get the BitBucket API to work for me, but have come to a grinding halt when it comes to getting it to work for a private repository with authentication (with the issues set as private, when they’re set to public and no authentication is needed it all works fine)

Code sample is as follows:

static void Main(string[] args)
    {
        WebProxy prox = new WebProxy("ProxyGoesHere");
        prox.Credentials = CredentialCache.DefaultNetworkCredentials;

        var address = "repositories/UserFoo/SlugBar/issues/1";
        var repCred = new CredentialCache();

        repCred.Add(new Uri("https://api.bitbucket.org/"), "Basic", new NetworkCredential("UserFoo", "PassBar"));


        WebClient client = new WebClient();
        client.Credentials = repCred;

        client.Proxy = prox;
        client.BaseAddress = "https://api.bitbucket.org/1.0/";
        client.UseDefaultCredentials = false;

        client.QueryString.Add("format", "xml");

        Console.WriteLine(client.DownloadString(address));
        Console.ReadLine();

    }

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:19:10+00:00Added an answer on May 24, 2026 at 8:19 pm

    I had the same problem recently, and I found two different solutions.

    First, vanilla .net with HttpWebRequest and HttpWebResponse:
    (this came from an answer here at Stack Overflow, but unfortunately I can’t find the link anymore)

    string url = "https://api.bitbucket.org/1.0/repositories/your_username/your_repo/issues/1";
    var request = WebRequest.Create(url) as HttpWebRequest;
    
    string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("your_username" + ":" + "your_password"));
    request.Headers.Add("Authorization", "Basic " + credentials);
    
    using (var response = request.GetResponse() as HttpWebResponse)
    {
        var reader = new StreamReader(response.GetResponseStream());
        string json = reader.ReadToEnd();
    }  
    

    Or, if you want to do the same with less code, you can use RestSharp:

    var client = new RestClient("https://api.bitbucket.org/1.0/");
    client.Authenticator =
        new HttpBasicAuthenticator("your_username", "your_password");
    var request = new RestRequest("repositories/your_username/your_repo/issues/1");
    RestResponse response = client.Execute(request);
    string json = response.Content;   
    

    By the way, I decided to use the HttpWebRequest solution for my own application.
    I’m writing a small tool to clone all my Bitbucket repositories (including the private ones) to my local machine. So I just make one single call to the Bitbucket API to get the list of repositories.
    And I didn’t want to include another library in my project just to save a few lines of code for this one single call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.