https://example.com/api/data?query=hello%20world
https://example.com/api/data?search=rock%26roll%3Dawesome%23fun
https://intranet.marinha.pt/search?term=marinha%20naval
https://intranet.marinha.pt/api/v1/search?term=opera%C3%A7%C3%A3o%20%C3%81gua&filter=tipo%3Drelat%C3%B3rio%26ano%3D2025&sort=nome%20asc
fetch("https://intranet.marinha.pt/api/v1/documentos?categoria=opera%C3%A7%C3%A3o&tipo=relat%C3%B3rio%26ano%3D2025&ordenar=nome%20asc", {
method: "GET",
headers: {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", // your token here
"Accept": "application/json",
"Content-Type": "application/json"
},
mode: "cors"
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Erro:", error));
https://intranet.marinha.pt/api/v1/documentos?categoria=opera%C3%A7%C3%A3o&tipo=relat%C3%B3rio%26ano%3D2025&ordenar=nome%20asc
{
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Accept": "application/json",
"Content-Type": "application/json"
}
fetch("https://intranet.marinha.pt/api/v1/documentos?categoria=opera%C3%A7%C3%A3o&tipo=relat%C3%B3rio%26ano%3D2025&ordenar=nome%20asc", {
method: "GET",
headers: {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Accept": "application/json",
"Content-Type": "application/json"
},
mode: "cors"
})
.then(response => response.json())
.then(data => console.log("✅ Dados recebidos:", data))
.catch(error => console.error("❌ Erro na requisição:", error));
{
"status": "success",
"data": [
{
"id": 101,
"titulo": "Relatório da Operação Água",
"ano": 2025,
"categoria": "operação",
"tipo": "relatório",
"autor": "Comando Naval",
"link": "https://intranet.marinha.pt/docs/101"
},
{
"id": 102,
"titulo": "Resumo Estratégico",
"ano": 2025,
"categoria": "operação",
"tipo": "relatório",
"autor": "Estado-Maior",
"link": "https://intranet.marinha.pt/docs/102"
}
]
}
https://intranet.marinha.pt/api/v1/documentos
{
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Accept": "application/json",
"Content-Type": "application/json"
}
{
"titulo": "Relatório da Operação Água",
"ano": 2025,
"categoria": "operação",
"tipo": "relatório",
"autor": "Comando Naval",
"descricao": "Análise detalhada da missão ÁGUA com foco em logística e segurança.",
"tags": ["estratégia", "água", "missão", "relatório"]
}
fetch("https://intranet.marinha.pt/api/v1/documentos", {
method: "POST",
headers: {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
titulo: "Relatório da Operação Água",
ano: 2025,
categoria: "operação",
tipo: "relatório",
autor: "Comando Naval",
descricao: "Análise detalhada da missão ÁGUA com foco em logística e segurança.",
tags: ["estratégia", "água", "missão", "relatório"]
}),
mode: "cors"
})
.then(response => response.json())
.then(data => console.log("✅ Documento criado:", data))
.catch(error => console.error("❌ Erro ao criar documento:", error));
{
"status": "created",
"id": 103,
"message": "Documento registrado com sucesso.",
"link": "https://intranet.marinha.pt/docs/103"
}
No comments:
Post a Comment