Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
chris05
Frequent Visitor

Get data using web API to Power BI - Token Prefix Missing

Hi,

I'm new to Power BI and I've been trying to connect data using API with Authentication in Get Data - WEB. I keep on getting "Token Prefix Missing" error.


I've tried all the steps I saw from the googel (use Basic, Advance - with/without Authorization in the header, add api key to username) 

 

The API URL with the Bearer token works fine in Postman, so I'm really not sure why it is not connecting in Power BI. 


Can someone help me please. 😢

 

chris05_0-1701198591511.png

 

 

5 REPLIES 5
Karltomm
Regular Visitor

Here is an example code I made for one API, the challenge I think is to understand what the API wants in the Headers and Body information. 

This is first step to get the Token, then you will need to use the token in a second call to the API where you GET the data you want. 

 

let
urlLogin="???",

 

//Body information with credential in this case
body = "{
""License"": ""??"",
""UserName"": ""??"",
""Password"": ""??"",
}",

 

//Create a JSON request to past to API
Parsed_JSON = Json.Document(body),
BuildQueryString = Uri.BuildQueryString(Parsed_JSON),

 

//Send and recive a replay inclusive the Access token.
GetTokenRecord = Json.Document(Web.Contents(urlLogin,[Headers = [#"Content-Type"="application/json",#"Accept"= "application/json"], Content = Text.ToBinary(BuildQueryString)])),

 

// Pick the token from the record, in this case the record was called Token in the table from the API.
token = GetTokenRecord[Token],

 

// Create the access token with Bearer in front if needed
access_token = "Bearer "&token,

in
access_token

 

 

Karltomm
Regular Visitor

Hi!
Do you know what type of API you try to connect to?

I never get the Get Data - Web to work, in my case it has been REST-API with credentials and token authorization. If its the same case for you, you will have to start with a Get Data - Blank Query and then write code were you pass your credentials and token to the API. 

You also need the API documentation to be able to see how and where the token and credentials should be passed.

Hope it can help you on your path to find the solution.

 

Hi Karl,
Thank you for your reply!
The API I'm trying to connect is from Ceipal (this is an applicant tracking system used for recruiting). The API documentation can be downloaded for each report that I will need from the site. I'm not really sure how to know the type of their API but as per their API documentation I have the below details

API NAME :  

Authentication Url :  
Username :  
Password :  
Auth Key :  {api_key:}
Format :  {json:1}  (0 for xml format)
Generate authtoken using this authentication and use this auth token to get the access for below API.

Authenticaiton type :  bearer token
token :  Token generated from authentication
Method :  GET
Endpoint URL : 



v-shex-msft
Community Support
Community Support

HI @chris05,

Perhaps you can take a look at the following blog about use web connector with optional parameters usages if it help for your scenario:

Using The RelativePath And Query Options With Web.Contents() In Power Bi 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

I'll be checking this! Thank you!

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.