I have a SpringBoot API with a POST end-point.
Trying to make a call to end-point from Grafana AJAX panel
It seems to be hitting the end-point but error occurs complaining about missing body.
error: "Bad Request" message: "Required request body is missing: public org.springframework.http.ResponseEntity status: 400
But the request has indeed a body.
Have been looking for possible POST examples for hrs now but no joy, e.g.
https://community.grafana.com/t/using-ajax-plugin-to-make-rest-call/6674
Any tips or solutions would be much appreciated.
Asked this same question on Grafana support forum.
Turns out the plugin/panel in question does not support POST with body.
Indeed, it looks like POST JSON data to backend is not currently supported. There seem to be two related issues here:
https://github.com/ryantxu/ajax-panel/issues/48
https://github.com/ryantxu/ajax-panel/issues/13
You're welcome to share your thoughts there, it looks like this feature request has been added as a future enhancement but I am not sure when that work will be completed. In the meantime, you may need to forego using the AJAX Plugin.
So it's basically useless as my backend API end-point requires a body.
try the new JSON API plugin
https://grafana.com/grafana/plugins/marcusolsson-json-datasource/?tab=changelog
or AjaxPanel plugin for more control
Related
I'm trying to use the search_after parameter with a point in time (PIT) to paginate search results. This is the documentation section I'm consulting.
I'm making a POST to /my-index/_pit?keep_alive=1m.
The /_pit endpoint only accepts the POST method (if I try GET, it says only POST is accepted), and per the doc, does not take a request body. However, the response I receive is a 400 with this message:
"type": "parse_exception",
"reason": "request body is required"
I can't find any other examples of a /_pit request and I'm just confused by these responses.
Has anyone successfully gotten back a PIT?
In case it's relevant, we have a managed elastic cloud deployment on a standard subscription.
I ended up finding an Elastic forum post indicating that the PIT API is only available as of version 7.10. Sure enough, I tried against a 7.10 deployment and it succeeded as a POST without a body.
So, I feel as though there isn't much guidance on this outside of this particular example and I felt the need to post this for other users that struggled as I did.
If you're using an API tool like postman, you have to update your headers to include Content_Type: application/json, and set your authorization method as what you need (I used basic for password and username).
The index that you should use (my-index-000001 from their example) should be one that you've set up for your search query (right before the _search portion). Leave the body empty and send over the post request and you'll get your id.
I made python function using AWS lambda and connected lambda with API Gateway
After then, I tested API. It worked well.
Testing in API Gateway was Successful
Now I tried to using this API with AJAX.
Javascript AJAX Code was like this
How ever result was
"jquery-3.4.1.js:9837 GET https://9i1jhuewmj.execute-api.ap-northeast-2.amazonaws.com/test/transaction?jpgname=image.jpg net::ERR_FAILED"
How can i solve this problem??
Hope for your wisdom!
Thank you
I think there are a few things. The content-type header being returned is application/json but the response is not JSON.
But I think the main problem is that the HTTP status being returned is 301. This tells the browser that this resource has been moved and the browser typically expects the response to contain information on where things are moved to so it can redirect.
I suspect if you change your configuration so that a more normal response code (i.e. 200) is returned, this will work better.
So, I set up a couple Lambdas and the API gateway. I got it all working! Cool, so then the next step was to require an API key. Ok cool plenty of resources out there on how to set it up.
So I got that working as well and I could POST using postman and python (requests). I can provide the 'x-api-key' in the headers of the POST and it works, no issues.
HOWEVER, and here's the problem: The program I'm going to ultimately be using to POST to my gateway API doesn't allow you to edit the details of your POST. The program is called splunk, here's what it looks like. Basically it posts some payload for you, the headers/auth/body can't be edited by you, it just sends some pre-configured thing. You just provide the endpoint and it does the rest. This works if I do not require an API key.
So I started thinking, ok no huge problem, I have seen APIs before where you provide the API-Key in the URL and it authenticates you fine. So this would be something like:
https://exampleAPI/sendmydata?x-api-key=12345
However, I cannot get this to work in AWS for the life of me. I haven't found anything by googling. Is this something that's even possible?
Thank you!
If you must use API key usage plans, you could consider getting the posted API key parameter to API Gateway endpoint A from LambdaA and proxy it with the relevant headers to API Gateway endpoint B.
I setup a GET scripted rest API. However, when I try to send a GET request with a body, ServiceNow (before it hits my code) complains that GET is not allowed to have a body.
Is there a way to disable this restriction? For now as a temporary workaround, I converted the request into a POST. However, this request does not change any state, so I believe it should be a GET. The request only searches for existing items.
GET is used without body, any configuration of a GET is in the URL and header. A query URL looks like this:
https://instance.service-now.com/api/now/table/problem?sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory&sysparm_limit=1
See the documentation here:
https://developer.servicenow.com/app.do#!/rest_api_doc?v=madrid&id=r_TableAPI-GET
Generally it's OK to use a POST to get data, graphQL does this for example, but i think SNOW is configured for GETs only.
I'm trying to migrate to Revocable Sessions with Parse. I haven't enabled it yet in the console because all my clients don't fully support it yet, but I was following Parse's blog post on migration and added X-Parse-Revocable-Session to my header using Parse's REST API. When I make the call I get the following back:
Request header field X-Parse-Revocable-Session is not allowed by Access-Control-Allow-Headers.
Then I checked the response header and noticed the following coming back from Parse:
Access-Control-Allow-Headers:X-Parse-REST-API-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, Content-Type
X-Parse Revocable-Session isn't in the list. Has anyone been able to get it working using the REST API? Am I missing something?
This is a bug on Parse side and has been confirmed by the team. https://developers.facebook.com/bugs/322026507921274/ . It will sorted soon.