Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Problem to connect with private BMC Rest API

Hello,

 

I am trying  to access and connect BMC remedy API but no luck.

Steps I followed : Common data Source (Web)-> provided the URL and hit connect but it says 

 

I know this API should be authorize but I do have the authorization header 

 

I tried th work around as I have seen in one of the post here.

https://community.powerbi.com/t5/Desktop/REST-API-web-data-source-Authentication-Header-is-gone/td-p/1009630

let
Source = Json.Document(Web.Contents("insert the URL here you used to in the regular way, and add ", [Headers=[Authorization="Basic insert your token here="]])),
issues = Source[issues],
       in
       Source 

 

but this one also giving an error : 

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

 

I have no idea how to fix it, anyone can assit me here.

 

Power BI Version : Version: 2.87.923.0 64-bit (november 2020)

 

Thanks

H.

 

 

4 Replies

  • Hi Anonymous 

    A 500 error indicates an internal server problem with the API /web server.  Perhaps something in the request you sent crashed it or maybe it's misconfigured - hard to say.

    Can you please share the actual query you are using, you can replace any sensitive info like password/username.

    How does the API specify that you should connect to it?  What documentation do you have that describes this?

    You say that it requires authentication - do you know what type?  Does it require an access token to be created before trying to retrieve data?

    Phil


    If I answered your question please mark my post as the solution.
    If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi PhilipTreacy 

      I just tried once again and follow the below and now I am able to connect with private API. yes It is authorized by token.

      let
      Source = Json.Document(Web.Contents("insert the URL here you used to in the regular way, and add ", [Headers=[Authorization="Basic insert your token here="]])),
      issues = Source[issues],
             in
             Source 

       

       

      My follow up question here.

      This token is expire in some interval, how I can refersh the token in Power BI itself

       

      Thanks

      H.

      • Anonymous's avatar
        Anonymous
        Not applicable

        There'@porwalhimanshu,

        I would like to suggest that you add the 'relativepath' parameter to the web connector and its request URL.
        AFAIK, sometimes these anonymous requests with header or other types of authorization content in the request cannot be used in the detailed URL. They only respond when sent to the root path.

        Using the RelativePath and Query options with Web.contents() in Power Query and Power BI M Code

        let
        	rooturl="https://xxxx.xxxx.com",
        	Source = Web.Contents(url,
        				[
        					Headers = [#"Authorization"='token', #"Content-Type"="application/json"],
        					RelativePath="/Api/arsys/entry/CTM:People",
        					Query =
        					[
        						q =xxxxxx,
        						id =xxxxxxx
        					]
        				]),
        	issues = Source[issues]
        in
            issues 

        Best regards

        Xiaoxin Sheng