Forum Discussion

SlavaSha7's avatar
SlavaSha7
Helper I
5 years ago
Solved

Error getting token for external web API (RingCentral)

I would like to get data from RingCentral to Power BI via eb API using M.

I was able to get token using Postman but I get error on Power BI with the same credentials

 

DataSource.Error: Web.Contents failed to get contents from 'https://platform.devtest.ringcentral.com/restapi/oauth/token' (404): Not Found
Details:
DataSourceKind=Web
DataSourcePath=https://platform.devtest.ringcentral.com/restapi/oauth/token
Url=https://platform.devtest.ringcentral.com/restapi/oauth/token

 

This is my M code:

let
    authKey = "Basic " & Binary.ToText(Text.ToBinary("<My API key>" & ":" & "<My Secret>"),0),
    Source = Json.Document(Web.Contents("https://platform.devtest.ringcentral.com/restapi/oauth/token", [Headers=[#"Accept"="application/json", #"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=authKey]])),
    #"Converted to Table1" = Record.ToTable(Source)
in
    #"Converted to Table1"

 

Thank you for your help.

 

Best regards,

Slava

  • You probably can't adapt the Twitter example directly and have it work with your RingCentral one.  I shared it as an example of dynamically getting an access token and then using it in query web calls.  How long does your access token last?  Are you able to do queries with the token hard-coded in?

     

    You should be able to see the actual web calls Power BI is making using Fiddler and maybe also with the Query Diagnostics tool within Power BI.

     

    I noticed that RingCentral has an API explorer to learn about use of their API.  Have you read all their documentation and used that explorer?

     

    Regards,

    Pat

4 Replies

    • SlavaSha7's avatar
      SlavaSha7
      Helper I

      Hi mahoneypat , thank you for your quick reply and helping,

      I downloaded your PBI file and tried with my URL and credentials, however I still receive error. What I add is username and password to the Content section as it required by RingCentral API and it works on Postman

       

      Perhaps the reason is with this requirement?
      "

      Request Headers

      The Content-Type header should be specified as application/x-www-form-urlencodedapplication/x-www-form-urlencoded Please note: Request body should be encoded appropriately. For example email [email protected] as username parameter should be specified so -john%2Bdoe%40example.com.

      "

       

      Can I somehow get the result JSON that Power BI sends to web API?

       

      Thanks for advance.

       

      Slava

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    You probably can't adapt the Twitter example directly and have it work with your RingCentral one.  I shared it as an example of dynamically getting an access token and then using it in query web calls.  How long does your access token last?  Are you able to do queries with the token hard-coded in?

     

    You should be able to see the actual web calls Power BI is making using Fiddler and maybe also with the Query Diagnostics tool within Power BI.

     

    I noticed that RingCentral has an API explorer to learn about use of their API.  Have you read all their documentation and used that explorer?

     

    Regards,

    Pat

    • SlavaSha7's avatar
      SlavaSha7
      Helper I

      mahoneypat thank you for your help!

      I installed Fiddler and found that the issue was with the symbol "+" on my password that was encoded incorrectly. I changed the password and it works now.

       

      Recently I was able to run on Power BI getting data with hardcoded token and obtain token via Postman. Now it works on Power BI as well.

       

      Thank you!

       

      Slava