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 6197619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:51:13+00:00 2026-05-24T03:51:13+00:00

I want to develop a java library for bitbucket issues API access. I’ve already

  • 0

I want to develop a java library for bitbucket issues API access.
I’ve already asked a question about the computation of the HTTP Content-Length header, but this question is specifically about the Bitbucket API and the process of updating an issue (since every other request works well).

The following code doesn’t work, giving a 411 Length Required error.
But even more confusing: In the documentation, you are told to use PUT request method. If you “forget” to specify that, status code changes to 200 OK, but leaving the issue unchanged.

public class PutTest {
    public static void main(String[] args) throws Exception {
        URL u = new URL("https://api.bitbucket.org/1.0/repositories/myname/myproject/issues/1/?title=hello+world");
        HttpURLConnection c = (HttpURLConnection) u.openConnection();
        c.addRequestProperty("Authorization", "Basic "+Base64.encodeToString("user:password".getBytes(), false));
        c.addRequestProperty("Content-Length", String.valueOf(u.getQuery().getBytes("UTF-8").length));
        c.setRequestMethod("PUT");
        c.connect();
        System.out.println(c.getResponseCode()+" "+c.getResponseMessage());
    }
}
  • 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-24T03:51:14+00:00Added an answer on May 24, 2026 at 3:51 am

    My updated code sample works, with help of another question at stackoverflow: How to send PUT, DELETE HTTP request in HttpURLConnection? Looks like not working.

    Utilizing connection’s OutputStream works.

    public class PutTest {
    
        public static void main(String[] args) throws Exception {
            URL u = new URL("https://api.bitbucket.org/1.0/repositories/myname/myproject/issues/1/");
            HttpURLConnection c = (HttpURLConnection) u.openConnection();
            c.addRequestProperty("Authorization", "Basic "+Base64.encodeToString(("user:password").getBytes(), false));
            c.setRequestMethod("PUT");
            c.setDoOutput(true);
            OutputStreamWriter out = new OutputStreamWriter(c.getOutputStream());
            out.write("title=hello+world");
            out.close();
            c.connect();
            System.out.println(c.getResponseCode()+" "+c.getResponseMessage());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a program using the Java MSN Messenger library ( JML
I want to develop a java servlet able to authenticate via HTTP protocol on
I want to develop Java apps, real quick, what IDE should I choose?
I've recently learned core Java and want to develop my skills further with practice
I want to develop a website with java but I'm absolute beginner in java
I want to develop a social networking web site in java. I want to
I am a Java beginner , I want to develop Android app , what
I want to develop Android apps on the Mac, but the information on http://developer.android.com/sdk/index.html
I am using Java to develop an application and I have a library that
I'm using Netbeans to develop a Java application and I want to create a

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.