ELK Dev tools API to create an alert - api

I want to create an alert rule using ELK dev tools. When I make it in the UI manually, I created like in the image.
I tried with the below code and got the mentioned issue. My elastic version is v 8.4.3.
# POST .monitoring-alerts-7/_create 400
{
"error": "no handler found for uri [/.monitoring-alerts-7/_create?pretty=true] and
method [POST]"
}
# { 400
{
"statusCode": 400,
"error": "Bad Request",
"message": "[request query.method]: Method must be one of, case insensitive
['HEAD', 'GET', 'POST', 'PUT', 'DELETE']. Received '{'."
}
Do I need to use a separate API?

Related

Random Network error on API call (axios post)

This is on a vuejs project, I use axios to make API calls.
I have the following API call :
await axios.post(`https://my-api.com/client/upload`,
formData,
{ headers: { 'Content-Type': 'multipart/form-data' }, withCredentials: true })
formData contains a pdf file.
And sometimes we get a Network error. This is the exception :
{
"message" : "Network Error",
"name": "Error",
"stack": "Error: Network Error\n
at t.exports (https://my-site.com/_nuxt/c3e2d4e.js:2:210975)\n
at w.onerror (https://my-site.com/_nuxt/c3e2d4e.js:2:209955)",
"config" : {
"url":"https://my-api.com/client/upload",
"method":"post","data":{},"headers":{"Accept":"application/json, text/plain, */*"},
"transformRequest":[null],"transformResponse":[null],"timeout":0,"withCredentials":true,
"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1
}
}
From what I see I get this error when a client tries to upload a specific file. They try several times with one file and it never works but if they switch device it works (with the same file). May be a false lead but that's what I can see from the logs.
Any idea how I can improve my logs to see the root of the problem ?

Strapi API register returning a 400 error

I’ve been creating a web app with a login and a registration function and so far everything has been going great. I managed to connect the app to the api/auth/local api endpoint and send some nice post requests.
Now, I’ve been trying to send requests to the http://localhost:1337/api/auth/local/register endpoint and without any success. I’ve been doing this according to:
https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#registration
I keep getting a 400 error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "An error occurred during account creation",
"details": {
}
}
}
If I try to send a request with an email that’s already registered in strapi, the response will give me the correct error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "Email is already taken",
"details": {
}
}
}
In the public and authenticated user roles, I’ve allowed every single one of them, for now.
Enable confirmation emails are set to false.
Email confirmation
Public user permission
For the headers, I’m using Content-type : application/json
the raw json body I'm posting:
{
"email": "manager1#strapi.io",
"password": "testtest1",
"username": "manager1"
}
This is my first project with strapi and so far it went pretty well. I’m not sure if I’m missing out on something or if I’m doing something else wrong.
Any help is appreciated!
I figured it out, it wasn’t as complicated as I expected.
In the user I had different fields, like firstName, lastName etc. All of these fields were required.
I made the fields not required, and now it works.

Shopware Product API response with no content and error 204 (No Content) Error

So while trying to test how to create a product, with as minimal data as possible, using the Shopware 6 API i get a Status 204 (No Content) response with an empty response.
When i press "Send" again i get a Status 400 error with this message:
{
"errors": [{
"status": "400",
"code": "CONTENT__DUPLICATE_PRODUCT_NUMBER",
"title": "Bad Request",
"detail": "Product with number \u002212345667891\u0022 already exists.",
"meta": {
"parameters": {
"number": "12345667891"
}
}
}]
}
When i check the Shopware Backend and search for the product, i get no result.
When i try searching the MySQL Product-Tables i get no result aswell.
Iam using this site: https://reqbin.com/
And I call the URL: https://www.my-url.de/api/product via POST Request.
As authorization i use a bearer token i grab from the getToken GET-Request.
My Request-Content looks like the following:
{
"name": "Aarons Testartikel of Doom",
"taxId": "f68a9c3c86864c2ea7597062fc457cf7",
"price": 3,
"productNumber": "12345667891",
"stock": 5,
"active": true
}
The 204 status code you get on your first request indicates that the request was handled successful. According to the HTTP-Standard all 2xx status codes can be considered successful. Shopware by default returns a 204 - No Content with en empty response body to all write requests over the API, but you can provide a _response query parameter to your POST-Request and Shopware will return a 200 response with the same data you'll get if you make a GET-Request to read the data of the added product.
In your case the URL would be https://www.my-url.de/api/product?_response=1.
The reason for the Error on the second request is that the product number needs to be unique, so you can't add another product with the same product number. Changing the product number before you do the second request should work again.
The Error also indicates that the first Write-Request was indeed successful, to make sure that your shopware installation is connected to the Database you think it is, you can check the .env file in the root folder of your installation, there should be a DATABASE_URL variable defined.

Fleet Api diferent from Route API - Invalid POI

Something isn't correct with HERE API:
This is working if I use https://route.api.here.com
https://route.api.here.com/routing/7.2/calculateroute.json?app_code=**APP_CODE**&app_id=**APP_ID**&waypoint0=geo!40.881402,-8.633051&waypoint1=geo!38.6143899,-1.1041018&mode=fastest;truck;traffic:enabled&language=pt-pt&routeAttributes=shape
This isn't working if I use http://fleet.api.here.com
http://fleet.api.here.com/2/calculateroute.json?app_code=**APP_CODE**&app_id=**APP_ID**&waypoint0=40.881402,-8.633051&waypoint1=38.6143899,-1.1041018&mode=fastest;truck;traffic:enabled&language=pt-pt
I received this error:
{
"issues": [
{
"message": "Cannot match 38.6143899/-1.1041018 onto a road link with 100.0m search radius"
},
{
"message": "Request id: 5c3aee72-e8f5-4c34-b96c-7c3e3cce5c02"
}
],
"response": null,
"error_id": "5c3aee72-e8f5-4c34-b96c-7c3e3cce5c02",
"response_code": "400 Bad Request"
}
But using the link https://tcs.ext.here.com/examples/v3/cost_optimized_route, I saw this:
Meanwhile, I research the API and if i increase the mapMatchRadius option to 500 m is working. It's very strange. The road exists in Here Maps. Someone from the Here Support Team can provide an input?

How to POST json parameters from Postman to Jenkins?

I need to call a Jenkins job using its API through Postman. This job requires parameters (HOST, VERBOSITY and PMSP).
Auth works using Jenkins token and header Content-type:application/json is used.
I tried to call the endpoint https://jenkins_server/job/job_name/build/api/json adding the following body to the request but the result is Nothing is submitted, and the job doesn't run.
I tried to call the endpoint https://jenkins_server/job/job_name/buildWithParameters/api/json adding the same body. I get 201 Created (job is running) but no parameters are given to the job.
{
"parameter": [
{
"name": "HOSTS",
"value": "[linux]\n1.2.3.4"
},
{
"name": "VERBOSITY",
"value": "vv"
},
{
"name": "SANS_PMSP",
"value": true
}
]
}
Is my JSON well constructed ? Which endpoint do I need to call ?
If it's Postman that you would like to focus on, you can import the curl command straight into the application.
This creates a new request for you to use and it populates this request, based on the details in the command.
From here, you should be able to add your own URL and point this at the location you need.