cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pbiembed Frequent Visitor
Frequent Visitor

Need help in connecting to REST API

Hi,

 

I was trying to Get Data from REST API which is working properly in Postman but unable to connect in power bi desktop.

 

Please find the error message below. Even if i use Anonymous its not connecting.

Details: "The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Referer"

Please help me out in resolving this issue.

 

Thanks,

Suma

9 REPLIES 9
Highlighted
blopez11 Established Member
Established Member

Re: Need help in connecting to REST API

I would be helpful to see your postman example and the M code for the query you are using on Power BI

pbiembed Frequent Visitor
Frequent Visitor

Re: Need help in connecting to REST API

Hi,

 

Please find the sample postman config.

GET http://serve:port/path
Authorization:"Basic <encoded String>"
Content-Type:text/plain
X-SECURITY_TOKEN:some codevalue
X-USER_TOKEN:email

 

And in power bi below is the power query

let
Source = "http://sample:700/path/",
Options= [
Headers=
[
#"Content-Type"="text/plain",
#"X-SECURITY_TOKEN"="token ",
#"X-USER_TOKEN"= "email@.com",
#"Authorization"="Basic encoded code"
]
],
result = Web.Contents(Source, Options),
toTable=Table.FromRecords({result})
in
Source

 

Please help me in resolving the issue.

 

Thanks,

Suma

blopez11 Established Member
Established Member

Re: Need help in connecting to REST API

Remove #"Authorization"="Basic encoded code" from the Headers in your M code, then in the Data source settings, change the permissions type from Anonymous to Basic, then you should be prompted for a user name and password.

Give that a shot

2019-07-31_17-50-14.jpg

 

pbiembed Frequent Visitor
Frequent Visitor

Re: Need help in connecting to REST API

Hi 

 

i have tried your solution but its not connecting.

 

Whereas its connecting in Postman with same credentials.Please find the screen belowBasicerr.png

 

 

 

 

 

 

 

 

Thanks,

Suma

blopez11 Established Member
Established Member

Re: Need help in connecting to REST API

Without seeing the full URL, it is kind of hard, but normally you authenticate against the base URL, so maybe change your M code to the following, by moving the portion after the base URL to the RelativePath option.  Additionally, if you are passing parameters as well in the URL, then those should move to the Query option

 

let
Source = "http://sample:700",
Options= [
RelativePath="PUT YOUR STATIC PATH, AFTER BASE URL HERE",
Headers=
[
#"Content-Type"="text/plain",
#"X-SECURITY_TOKEN"="token ",
#"X-USER_TOKEN"= "email@.com",
]
],
result = Web.Contents(Source, Options),
toTable=Table.FromRecords({result})
in
Source

pbiembed Frequent Visitor
Frequent Visitor

Re: Need help in connecting to REST API

Hi,

 

I am trying to connect to Amazon Web services.

 

So the url is an ec2 instance Ex:http://ec2-servername:port.

 

I have tied connecting by passing Relative path in options but i got below issue.

 

With_Relative_path.JPG

 

Thanks,

Suma

blopez11 Established Member
Established Member

Re: Need help in connecting to REST API

Unfortunately without being able to troubleshoot it myself, I probably can't help any further

Maybe someone else on the community has more experience with your particular use case

Good luck,

pbiembed Frequent Visitor
Frequent Visitor

Re: Need help in connecting to REST API

Ok Thank You for your assistance.

 

Thanks,

Suma

pbiembed Frequent Visitor
Frequent Visitor

Re: Need help in connecting to REST API

Hi 

 

Can anyone please assist me on this issue.

 

Thanks,

Suma

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 140 members 1,602 guests
Please welcome our newest community members: