I am writing an application to communicate with BB Server via the REST API. The REST API documentation seems to be a bit incomplete and I’m having difficulty figuring out exactly how to download non-text files from a BB Server repository.
The following curl command successfully downloads a pdf file from BB server. The binary content of the file is returned in an HTTP chunked response with Content-Type: application/pdf. Note that the URI does not include “rest/api/1.0”:
curl --output - -v -X GET -u [creds] http://[host-ip]:7990/projects/DICK/repos/codedronediy/browse/Datasheets/Accelerometer-and-Gyroscope-Design-Guidelines.pdf?raw
If we run the same command with “rest/api/1.0” prepended to the previous URI, a response is returned with Content-Type: application/json, and the JSON object in the HTTP response body contains brief file metadata describing the file (with keys “binary” and “path”):
curl --output - -v -X GET -u [creds] http://[host-ip]:7990/rest/api/1.0/projects/DICK/repos/codedronediy/browse/Datasheets/Accelerometer-and-Gyroscope-Design-Guidelines.pdf?raw
The first example returns the data from the binary file exactly as I wish: as chunked binary data with Content-Type: application/pdf. However the endpoint I’ve addressed in my request is not in the Bitbucket REST API so this may not be a reliable approach in general. The second example uses the seemingly correct REST endpoint to access the file data, but that endpoint returns only file metadata, not actual content (even with “?raw” query parameter)
Can you provide a REST API endpoint (and all required query parameters) that will allow me to download arbitrary binary file content from a BB Server repository? And if you can provide a complete description of the REST API used to download binary files that would be useful. Thanks!