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.
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,
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}"]])),
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,
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
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |