Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Connect to REST API using X-AUTH-TOKEN and POST method (ERROR : please specify how to connect)

Hello everybody, i tried to connect to rest api using X-AUTH-TOKEN and POST method but i got this error :

 

Please specify how to connect

 here is the code :

let
url = "https://centreon.xxxxxxx/centreon/api/v2/login",
GetJson = Web.Contents(url,
[
Headers = [#"Accept"="application/json",
#"Content-Type"="application/Json"],
Content = Text.ToBinary("{""security"": {""credentials"": {""login"": ""xxxxxxxx"",""password"": ""xxxxxxxx""}}")
]
),
FormatAsJson = Json.Document(GetJson),
// Gets token from the Json response
AccessToken = FormatAsJson[token],
AccessTokenHeader = "X-AUTH-TOKEN " & AccessToken,
GetJsonQuery = Web.Contents("https://centreon.xxxxxxxx/centreon/api/beta/monitoring/hosts/",
[
Headers = [#"Authorization"=AccessTokenHeader]
]
),
FormatAsJsonQuery = Json.Document(GetJsonQuery)
in
FormatAsJsonQuery

in postman i got the right result with this information

curl --location --request POST 'https://centreon.xxxxxxxx/centreon/api/v2/login' \
--header 'Content-Type: application/json' \
--data-raw '{
  "security": {
    "credentials": {
      "login""xxxxxxxxxx",
      "password""xxxxxxxxxxx"
    }
  }
}'

and

curl --location --request GET 'https://centreon.xxxxxxxx/centreon/api/beta/monitoring/hosts/' \
--header 'X-AUTH-TOKEN: xxxxxxxxxxxxxxxx'

Thank you in advance for your answers,

4 REPLIES 4
JeffManley
Frequent Visitor

In case you still needed an answer for this...the following worked for me

 

let
Source = Json.Document(Web.Contents("{add URL here}", [Headers=[#"Content-Type"="application/json", #"X-ApiToken"="{add token here}"]])),

AbirEzzahra
New Member

Hello, 

I really hope you have found the solution. If yes, would you please share it with us ? I am facing the same problem. 

thank you, 

Anonymous
Not applicable

hi, i am sorry i did not find a solution for this problem but i proceeded otherwise to resolve it. indeed I used an etl (talend) to establish the connection with Centreon and to import the necessary data into my data warehouse to then retrieve them on power bi. I hope it can help you.

Good luck

 

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

You may refer to this blog for more details: Web Services And POST Requests In Power Query

You can try Anonymous access, for more details: Anonymous access

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.