I'am trying to access to my logs stored on logz.io using api-search that they offer me.
Actually, I can access successfully using curl command as I show:
curl -X POST 'https://api.logz.io/v1/search'
--header "X-API-TOKEN: API-TOKEN-GENERATED"
--header "Content-Type: application/json"
-d '{"query": {"term": {"_id": {"value": "Log Id Here"}}}}',
just like https://github.com/logzio/public-api/tree/master/search said.
However, when I use AWS AppSync api, using HttpResolver datasource with params name:HttpDataSourceTest, type:HTTP and endpoint:https://api.logz.io/v1/search, I defined my schema.grapqhl, the request and response template resolvers:
schema.grapgql
type Query {
GetLog(id: String): Log
}
Request Template Resolver:
{
"version": "2018-05-29",
"method": "POST",
"params": {
"headers": {
"Content-Type: application/json",
"X-API-TOKEN":"API-TOKEN-GENERATED"
},
"body":{
"query": {
"term": {
"_id": {
"value": "$context.arguments.id"
}
}
}
}
},
"resourcePath": "/"
}
Response Template Resolver:
$utils.toJson({"TimeStamp":"$ctx.result.statusCode $ctx.result.body" })
After several attemps and fails I kept very simple, just ask for TimeStamp field on query and show status and all returned in response.
After all this configurations i get this response:
{
"data": {
"GetLog": {
"TimeStamp": "403 {\"message\":\"Forbidden\"}"
}
}
}
The same result when I skip X-API-TOKEN param header, its like HttpDatasource dont send that params. I am new using all this techs, AWS Services and Logz.io, please tell me if I'm omitting something in some place.