Forum Discussion

frano72's avatar
frano72
Icon for Helper IV rankHelper IV
5 years ago
Solved

Connection to external API via Dataflow (or Desktop) - "The 'Authorization' header is only suppo..."

Ok, so if i could print out all the pages i've read on this this afternoon and put on a wall it would look like one of those information (murder ?)walls from your favourite cop show.

 

I am trying to connect to a platform via an API using dataflows.

 

I have a postman query working and it returns three token values.  Evidence below.

 

 

Do you think i could replicate this in PQ in Service or PBI Desktop !

 

let
  
  token_path = "v1/auth",
  Username = "mytopsecretusername",
  Password = "myevenmoresecretpassword",
  EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(Username & ":" & Password), BinaryEncoding.Base64),
  Token_Response = Json.Document(Web.Contents(api_url,
    [ 
      RelativePath = token_path,
      Headers = [#"Authorization"=EncodedCredentials,#"Content-Type"="application/json"]
    ]      
    )
    )
in
  Token_Response

 

Now according to API spec (SmartCap API Documentation (smartcaplife.com)) it needs to be a POST so I know i need a contents section to the web.contents call...but i'm not following what to set that as ?

 

The error i get at the moment is around authorisation and anonymous connections as per below.

 

Expression.Error: 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, Range, Referer

 

Any ideas ?

2 Replies