Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I need to connect in API with method POST and authorization token, but the response is 404 or 400.
I tried with M language:
let
Json = Json.FromValue({[idType= "Authorization", idValue= "KEY123"]}),
Source = Json.Document(Web.Contents("https://apiintegracao.milvus.com.br/api/chamado/listagem", [Headers=[#"Content-Type"="application/json"]]))
in
Source
And I tried with Web Data Source, and not works?
The API link I'm trying to connect:
https://developers.milvus.com.br/#api-Chamado-listagemChamados
Anyone can help me, please?
Sorry about my level English.
Use a Python script being read directly by Power BI to query the API. Refer to the API https://developers.milvus.com.br/#api-Chamado-listagemChamados documentation to modify the parameters and the filter body ('filtro_body')
import requests
import pandas as pd
import json
url = "https://apiintegracao.milvus.com.br/api/chamado/listagem"
# Add Query Param to the URL
url += "?total_registros=1000"
payload = json.dumps({
"filtro_body": {
"status": 4,
}
})
headers = {
'Content-Type': 'application/json',
'Authorization': '123token'
}
response = requests.request("POST", url, headers=headers, data=payload)
# Parse the JSON response
data = response.json()
# Check if the response was successful
if 'lista' in data:
# Convert the response data to a DataFrame
df = pd.DataFrame(data['lista'])
# Select and organize columns
columns_to_select = ["codigo", "cliente", "contato", "categoria_primaria", "categoria_secundaria", "tecnico", "total_horas", "data_criacao", "data_solucao", "servico_realizado"]
if all(col in df.columns for col in columns_to_select):
df = df[columns_to_select]
# Format date columns, if necessary
df["data_criacao"] = pd.to_datetime(df["data_criacao"])
df["data_solucao"] = pd.to_datetime(df["data_solucao"])
# Display DataFrame in tabular format
print(df.to_string(index=False))
else:
print("Some specified columns are not present in the DataFrame returned by the API.")
# Add logic here to handle the situation of missing columns, if necessary.
else:
print("Error in API response:", data)
I tried, but not works too.
Now, I'm trying this way:
let
content = "{""filtro_body"": ""123""}",
Source = Json.Document(Web.Contents("https://apiintegracao.milvus.com.br/api/chamado/listagem",
[Headers=[#"Authorization"="token",
#"apikey" = "****",
#"filtro_body" = "{}",
#"ContentType"="application/json"],
ManualStatusHandling = {404, 400},
Content=Text.ToBinary(content)]))
in
Source
And not works too, but show me another message "Parameter not informed in the request body => {filtro_body}"
I added the parameter 'filtro_body", but the message remains
Authorization also needs to be added to the Header. Please try again after making the header changes
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 |
User | Count |
---|---|
8 | |
6 | |
4 | |
4 | |
4 |