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

Importing Raw Text File into Power BI

Luke D_Anastasi April 17, 2024

Hi,

 

I am trying to import a raw text file from a repo I have in bitbucket into power bi, but I get a file note found. Once I import this file, I want to evaluate the query ( I know how to do this) but I can't get access to the text file.

Can anyone tell me what syntax I need?

 

let
// Define the URL of the API endpoint
url = "https://bitbucket.org/broadspectrum/bustthetape/raw/7f104785464107f192272d47c30cf2766c57ea13/70061.txt",

// Set up the HTTP headers to include the Bearer token
headers = [
#"Authorization"="Authorization: Bearer Token"
],

// Get HTML content from the API
Source = Text.FromBinary(Web.Contents(url, [Headers=headers])),

// Example of parsing HTML content:
// This is a simplistic example where we look for a specific tag or pattern.
// This will need to be adjusted based on the actual HTML structure you're dealing with.
startIndex = Text.PositionOf(Source, "<tag>"),
endIndex = Text.PositionOf(Source, "</tag>"),
extractedValue = Text.Middle(Source, startIndex, endIndex - startIndex + 5) // Adjust length based on tags

// More complex parsing might be needed based on the HTML structure
// You might also need to split the text, extract parts using Text.BetweenDelimiters, etc.
in
extractedValue

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 21, 2024

G'day, @Luke D_Anastasi 

Welcome to the community!

I believe you can't use the direct URL raw files if you are making an API request. You should use the following example:

https://api.bitbucket.org/2.0/repositories/<Workspace>/<Repo>/src/<commit>/<filepath>

Do note that you are required to log in with username app_password to authenticate.

Regards,
Syahrul

Luke D_Anastasi April 21, 2024

Thanks Syahrul, can't I add an api token to the address to authenticate?

How would the syntax look like?

I literally just want to import the code I have in the text file, so I can then evaluate those instructions in Power Query.

Using a the RAW URL with Git works, but bitbucket I get a 404.

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 21, 2024

Hey @Luke D_Anastasi 

I'm not an expert on Power Query, so I can't offer much help in that area. However, I can provide you with an example of how to obtain files using Curl:

curl -X GET -u <username>:<app_password> https://api.bitbucket.org/2.0/repositories/<Workspace>/<Repo>/src/<commit>/<filepath> --output file.csv

If you wish to use Token, please check our documentation on how to generate tokens and use them at:

https://developer.atlassian.com/cloud/bitbucket/rest/intro/#repository-access-tokens

For example, using a Repository access token:

https://support.atlassian.com/bitbucket-cloud/docs/using-access-tokens/

Regards,
Syahrul

 

Luke D_Anastasi April 21, 2024

Power BI cannot deploy cURL commands. 

Is there way I can do this via the REST API?

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 22, 2024

Hey @Luke D_Anastasi 

Noted. If that's the case I suggest asking this type of question directly on our community developer page at:

https://community.developer.atlassian.com/c/bitbucket-development/12

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events