I am trying to query Kibana logstash through python.
In the logstash I would want to get this field json.correlation_id: "{json.correlation_id}"
query = json.dumps({
"query": {
"json.correlation_id": "json.correlation_id"
}
})
r = requests.get(uri,auth = HTTPBasicAuth(username,
password),headers=HEADERS, data=query).json()
print(r)
but I get an error message
{'statusCode': 404, 'error': 'Not Found', 'message': 'Not Found'}
How do I actually write the code to query the logstash?
Related
Apache Flink provides a set of Rest API. When my flink job is running, I tried to access the job using /jobs and it gave me the metadata information. When i tried to fetch the results using /job/:jobid/execution-result, I got the result as {status: "RUNNING"}. Upon stopping I get the response as
{
"status": {
"id": "COMPLETED"
},
"job-execution-result": {
"id": jobid,
"application-status": "CANCELED",
"accumulator-results": {},
"net-runtime": 1872358
}
}
Is there a way I can get the results that get printed on flink std out using any other API calls?
I am using Marshmallow to validate incoming fields for a simple put request.
Now I am testing the error handling in the frontend to make sure I send the right error messages for the frontend.
I am usually sending data of type
{
password: string,
email: string
}
For now Marshmallow checks if the password is long enough and if the email is of format Email.
I collect all errors in a expect statement and send it to the frontend like this:
except ValidationError as err:
return make_response(
{"errors": err.messages}, status.HTTP_400_BAD_REQUEST
)
with Postman giving me e.g. this response:
{
"errors": {
"email": [
"Missing data for required field."
],
"password": [
"Missing data for required field."
],
}
}
All error messages are therefore collected within the field errors and sent back to the frontend.
When the error is sent back to the frontend I catch my error and all I get is this object:
Object {
"data": null,
"error": [Error: Request failed with status code 400],
}
How do I correctly send or receive the
errors: err.messages
field in the frontend within a make_response error response?
I found the solution to the problem I had here:
github.com/axios/axios/issues/960.
Apparently you have to access the response object or the error object that is send to axios. There is no interceptor needed. What I changed was this line, when resolving the promise to:
try {
resolved.data = await promise;
} catch (e) {
resolved.error = e.response.data;
}
before that I accessed the error with:
try {
resolved.data = await promise;
} catch (e) {
resolved.error = e;
}
The errors are stored within the response.data.
Trying to create a subscription to get a channel for msgraph one drive notifications for file creation/upload.
I am hitting the URL -
https://graph.microsoft.com/v1.0/subscriptions
with proper headers and the following body -
{
"changeType": "updated",
"notificationUrl": "https://xxxxx.xxxxxxxxx.com/zzzz/qwertqwert",
"resource": "/users/{user-id}/drive/root",
"expirationDateTime": "2017-02-18T19:49:40.000Z",
"clientState": "justsomerandomstring"
}
I am getting the following response :
400 Bad Request Error
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
"innerError": {
"request-id": "2862896286-5415-4921-gbn5-8741288985",
"date": "2017-02-17T17:30:22"
}
}
}
I was making the same request 30-32 hrs back. Was getting the subscription-id as well as the file notifications on my redirection servlet.
Not able to figure out what changed. Couldn't find any helping documentation either
Got the same error here and it took me a while to find out what is the problem so I share this with you here.
Here's the working code:
$subscription = new Subscription([
'resource' => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27',
'notificationUrl' => 'https://my.domain.fr',
'changeType' => 'updated',
'expirationDateTime' => date(DATE_ISO8601, strtotime('+48 hours'))
]);
The line which was wrong for me is:
'resource' => 'me/messages/' . $draftEmail->getParentFolderId(),
And i replace it with
'resource' => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27',
I found my answer in this link: https://msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations#subscribe-to-changes-in-my-mail-calendar-contacts-or-tasks
But in my opinion the "resource" parameter should be more documented on graph api documentation and the error message return must specify WHY this is a BadRequest.
Using beta api version solved my problem,
https://graph.microsoft.com/beta/subscriptions
I'm trying to handle specific response codes in my Angular2 app. I have this code:
handleError(res: Response) {
console.log('Response status is %d', res.status);
if (res.status === 403) {
logUserOut();
}
}
The log statement there prints out Response status is 403, but the if statement is not true. Looking at the actual response object, it does look like the status is 403 and is an int. My first guess would have been the if statement is evaluating to false due to a different type. its a int not a string? I haven't tried using == instead of === because my linter would complain and not transpile. In any case, I'm trying to figure out why this seemingly true statement is evaluating to false.
What is the best way to catch exceptions in the response payload for API calls made to the Yodlee REST Aggregation API?
Historically speaking I've seen {'Error' => [{'errorDetail' => 'some error message'}]}, but I've also seen {'errorOccured' => true, 'exceptionType' => 'some documented exception type', 'referenceCode' => ''}.
The documentation suggests I can expect exceptionType, but I'd like to be sure. The API call I'm currently most concerned with is /login.
Here are types of error code format which you can expect-
JSON exception format 1:
{
"errorOccurred": "true",
"exceptionType": "com.yodlee.core.SiteNotFoundException",
"referenceCode": "_afe4ae60-68fe-4443-a721-d97a192e9455",
"message": "Argument value not found: 164413432"
}
JSON exception format 2 (Same as format 1, but "message" attribute is missing so considered as additional):
{
"errorOccurred": "true",
"exceptionType": "Exception Occurred",
"referenceCode": "_5c4d1347-cb4a-4404-809b-57dbfabcf1db"
}
JSON exception format 3:
{
"Error": [
{
"errorDetail": "No session ID found "
}
]
}
JSON exception format 4 (Same as format 3, but "errorDetail" attribute is missing so considered as additional):
{
"Error": [
null
]
}
JSON exception format 5:
{
"errorDetail": "Token authentication failed for cobrand/user Invalid cobrand conversation credentials"
}
This will cover almost all the scenarios.