Forum Discussion

NiharTestIngram's avatar
NiharTestIngram
Regular Visitor
3 years ago
Solved

The 'Authorization' header is only supported when connecting anonymously from sonar cloud API

Hi Team,

 

I am getting below error while trying to fetch data from sonar cloud API using basic authentication. where as same API is working fine in postman. can someone help me on how to resolve this for all repository.

 

I tried different forums where it's mentioned to used datasource connection as anonymous. but there also i am getting issue 

Then i tried with with basic authentication but getting the Authorization header error for all repositories.

Tried this query

= Json.Document(Web.Contents("https://sonarcloud.io/api/measures/component?component=imonline_accountmanagement.webapi.reseller&metricKeys=bugs,vulnerabilities,security_hotspots,security_hotspots_reviewed,code_smells,coverage,duplicated_lines_density,duplicated_blocks,ncloc,tests,uncovered_lines,sqale_rating,reliability_rating,security_rating,security_review_rating&branch=master", [Headers=[Authorization="Basic NGZhNmFkZDFhNmMyNDRkMjdlNjI0MDVjYTQ3YWJmNjhmNzdiYjI0Njo="]]))

 

can you please help me here how to solve this issue.

 

Thanks

Nihar Arisal

  • HI @Daryl-Lynch-Bzy ,

     

    Its now working. i just removed authorization from power query as token is used for data source connection.

     

    let
    Source = Json.Document(Web.Contents("https://sonarcloud.io/api/measures/component?component=imonline_accountmanagement.webapi.reseller&me...")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded component" = Table.ExpandRecordColumn(#"Converted to Table", "component", {"id", "key", "name", "qualifier", "measures"}, {"component.id", "component.key", "component.name", "component.qualifier", "component.measures"}),
    #"Expanded component.measures" = Table.ExpandListColumn(#"Expanded component", "component.measures"),
    #"Expanded component.measures1" = Table.ExpandRecordColumn(#"Expanded component.measures", "component.measures", {"metric", "value", "bestValue"}, {"component.measures.metric", "component.measures.value", "component.measures.bestValue"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded component.measures1",{{"component.id", type text}, {"component.key", type text}, {"component.name", type text}, {"component.qualifier", type text}, {"component.measures.metric", type text}, {"component.measures.value", Int64.Type}, {"component.measures.bestValue", type logical}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"component.id", "component.key", "component.qualifier","component.measures.bestValue"})
    in
    #"Removed Columns"

     

    Thanks

    Nihar

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi NiharTestIngram  - can you please try wraping Authorization with #"" so it appears as #"Authorization"? 

    • NiharTestIngram's avatar
      NiharTestIngram
      Regular Visitor

      HI Anonymous ,

      I tried with that option also but same result.

      let
      Source = Json.Document(Web.Contents("https://sonarcloud.io/api/measures/component?component=imonline_accountmanagement.webapi.reseller&metricKeys=bugs,vulnerabilities,security_hotspots,security_hotspots_reviewed,code_smells,coverage,duplicated_lines_density,duplicated_blocks,ncloc,tests,uncovered_lines,sqale_rating,reliability_rating,security_rating,security_review_rating&branch=master", [Headers=[#"Authorization"="Basic NGZhNmFkZDFhNmMyNDRkMjdlNjI0MDVjYTQ3YWJmNjhmNzdiYjI0Njo="]])),
      #"Converted to Table" = Table.FromRecords({Source}),
      #"Expanded component" = Table.ExpandRecordColumn(#"Converted to Table", "component", {"id", "key", "name", "qualifier", "measures"}, {"component.id", "component.key", "component.name", "component.qualifier", "component.measures"}),
      #"Expanded component.measures" = Table.ExpandListColumn(#"Expanded component", "component.measures"),
      #"Expanded component.measures1" = Table.ExpandRecordColumn(#"Expanded component.measures", "component.measures", {"metric", "value", "bestValue"}, {"component.measures.metric", "component.measures.value", "component.measures.bestValue"}),
      #"Changed Type" = Table.TransformColumnTypes(#"Expanded component.measures1",{{"component.id", type text}, {"component.key", type text}, {"component.name", type text}, {"component.qualifier", type text}, {"component.measures.metric", type text}, {"component.measures.value", Int64.Type}, {"component.measures.bestValue", type logical}}),
      #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"component.id", "component.key", "component.qualifier","component.measures.bestValue"})
      in
      #"Removed Columns"

       

      Getting same issue for all the. and using same basic auth, it is working fine in postman. but not in power BI.

      for that error it did not allow me to apply the changes as well.

       

       

      Thanks

      Nihar

       

  • HI @Daryl-Lynch-Bzy ,

     

    Its now working. i just removed authorization from power query as token is used for data source connection.

     

    let
    Source = Json.Document(Web.Contents("https://sonarcloud.io/api/measures/component?component=imonline_accountmanagement.webapi.reseller&me...")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded component" = Table.ExpandRecordColumn(#"Converted to Table", "component", {"id", "key", "name", "qualifier", "measures"}, {"component.id", "component.key", "component.name", "component.qualifier", "component.measures"}),
    #"Expanded component.measures" = Table.ExpandListColumn(#"Expanded component", "component.measures"),
    #"Expanded component.measures1" = Table.ExpandRecordColumn(#"Expanded component.measures", "component.measures", {"metric", "value", "bestValue"}, {"component.measures.metric", "component.measures.value", "component.measures.bestValue"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded component.measures1",{{"component.id", type text}, {"component.key", type text}, {"component.name", type text}, {"component.qualifier", type text}, {"component.measures.metric", type text}, {"component.measures.value", Int64.Type}, {"component.measures.bestValue", type logical}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"component.id", "component.key", "component.qualifier","component.measures.bestValue"})
    in
    #"Removed Columns"

     

    Thanks

    Nihar

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi NiharTestIngram - I am having a similar issue with a different API. Would you mind demonstrating where and how exactly you removed the authorization bit from the query? I know it's been awhile. Thank you in advance

  • Hi all,

     

    i have the same issue with fetching EHS insights data from API. the refresh in powerbi service wont work and gives the same message. 

    I tried removing the header and then swithing to basic authentication by using my username and the API key for te key after that i published the file. i also changed the data source credentials to same what i did in the desktop file but when i then refresh, i still seem to get the error.

    Any help?