Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket api upload zip file lost content any idea or help Edited

I am trying to upload a zip file via bitbucket org api. I tried to do this with postman, insomina, curl and php script. I am using the url{myAccount}/{myRepoName}/src and add the file according into client. 


For php script i used httpful for example. My problem is that the zip file is added successful with my commit message and the location where i want to add the file. but when i do git pull my_branch and i try to unzip the file it says "Unable to expand", It is in an unsupported format. 


Would appreciate if someone can help me out to understand and fix this issue. 





The Curl code is as follow 



$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"\"\r\n\r\n@/Users/user/Downloads/\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\nzipfile from postman\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
"Accept: */*",
"Accept-Encoding: gzip, deflate",
"Authorization: Basic token",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Content-Length: 353",
"Content-Type: multipart/form-data; boundary=--------------------------629401965265661450958266",
"Postman-Token: 2f8d1349-540f-4a13-97f6-6a972075eda5,b693c61a-4423-41fc-aa19-4686bf3a2716",
"User-Agent: PostmanRuntime/7.20.1",
"cache-control: no-cache",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"

$response = curl_exec($curl);
$err = curl_error($curl);


if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;



where as the php code is as 


$sourceFileInfo = $this-> getFileRealName($this->getFile());$url = sprintf("{$bitbucketSettings->userName}/{$bitbucketSettings->repoName}/src");        $base64 = base64_encode($bitbucketSettings->userName.':'.$bitbucketSettings->password);        $commitMessage = "This is the commit from my application";$body = array (
            'message' => $commitMessage,
            'file' => $sourceFileInfo['actualPath'],
            'branch' => $this->getSettings()->branch,
            'folder' => '/'.$bitbucketSettings->folder . '/'. $sourceFileInfo['realName']
        );$response = \Httpful\Request::post($url)
            ->addHeader('Authorization', "Basic $base64")
            ->addHeaders(                array(
                    'Accept-Encoding' => 'gzip, deflate',
                    'Host'  => '',
                    'Cache-Control' => 'no-cache',
                    'Accept' => '*/*',
                "&message=" .$body['message'].
                "&{$body['folder']}=" .base64_encode(file_get_contents($body['file']))
            -> send(); 


1 answer

Is it there any kind of content type issue? 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,124 views 0 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you