Unable to import Kibana Dashbord using api - amazon-web-services

I exported a dashboard and have been attempting to import it using the Kibana API.
On making the below curl request
curl -X POST -u <USERNAME>:<PASSWORD> <URL> -H "kbn-xsrf: true" --form file=#export.ndjson -H 'kbn-xsrf: true'
I'm getting the response as:
{"error":"Content-Type header [multipart/form-data; boundary=------------------------0506088858c35b19] is not supported","status":406}%
Note: I'm using AWS managed Opensearch
Can someone help me to please fix this error?
Thanks in advance :)

I was able to fix this issue by augmenting few header key-val pairs.
'kbn-xsrf': 'true',
"Accept": "*/*",
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
"Accept-Encoding": "gzip, deflate, br",
'osd-xsrf': 'true'

Related

POST, PUT and PATCH resources not working in WSO2 Api Gateway

I am quite new to the WSO2 tools. I recently started using the WSO2 API Manager(ver. 3.1.0).
I created an API gateway by importing the httpbin swagger specs: https://github.com/Azure/api-management-samples/blob/master/apis/httpbin.swagger.json. I published the API, subscribed to it, generated the API keys and started testing.
I imported the spec in Postman, configured the API key for authorization, changed the server to the local gateway http://localhost:8280/Api_Base/1.0
All the resources defined with GET method were accessible, but the POST, PUT and PATCH resources
were not reachable via the gateway. I received the following error response "<faultstring>unknown" for these resources. I tried with cURL as well but got the same results. When I tried POST for httpbin directly it was working just fine:
curl --location --request POST 'http://httpbin.org/post'
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.58.0",
"X-Amzn-Trace-Id": "Root=1-5e8e0d39-ddf21f1055008f60707cf150"
},
"json": null,
"origin": "95.103.xxx.xxx",
"url": "http://httpbin.org/post"
}
and via my API gateway(with API key as well):
curl --location --request POST 'http://localhost:8280/HTTP_Bin_Mock/1.0/post'
<faultstring>unknown</faultstring>
What could have gone wrong?
please try below CURL command
curl --location --request POST 'http://localhost:8280/HTTP_Bin_Mock/1.0/post' --data '{}' --header 'Content-Type: Application/JSON'

Import a standard http request in postman?

I have a simple HTTP request :
POST /a/b/c HTTP/1.1
Host: localhost:17814
Content-Type: application/json
jwt: x.x.x
{
"requestId": "E1EC8B9E-A78E-443A-B2A9-8D6F7692B63C"
}
I don't have another format. It's a basic HTTP standard request structure.
I want to invoke it in Postman.
But it seems that when I try to "Import" it in postman it says :
Question:
Is there any way to import standard HTTP requests in postman? there must be. it's the standard syntax
The Import feature only supports certain formats.
Import a Postman Collection, Environment, data dump, curl command, or
a RAML / WADL / Open API (1.0/2.0/3.0) / GraphQL Schema / Runscope
file
I guess that would be something this in curl:
curl -X POST 'localhost:17814/a/b/c' \
-H 'jwt: x.x.x' \
-H 'Content-Type: application/json' \
-d '{
"requestId": "E1EC8B9E-A78E-443A-B2A9-8D6F7692B63C"
}'
You can import that format into the app and it should create the request.

Why did my POST to AWS API Gateway failed?

I use POSTMAN to test my Cloudformation created APIs
POST https://6pppnxxxh.execute-api.eu-central-1.amazonaws.com/Prod/users
I got
{
"message": "Missing Authentication Token"
}
My prod stage
I doublechecked PROD Invoke URL.
How to solve this problem?
I tried with curl
curl --header "Content-Type: application/json" --request POST --data '{ "emailaddress" : "acj#rambler.ru,"first name" : "Aca","last name" : "Ljubascikic", "password" : "bbbac_96"}' https://6pppnxxxh.execute-api.eu-central-1.amazonaws.com/Prod/users
The same issue
{"message":"Missing Authentication Token"}
How to test from CLI?
According to your screenshot /Prod/users is a PUT method and you are using POST in your command. I would confirm that first.
Hope this helps.

django-oauth-toolkit 'invalid client' error after deploy on AWS Elasticbeanstalk

I use django-oauth-toolkit with my django/django-rest-framework application. When I request an access token in dev mode on localhost, it works OK:
dev#devComp:$ curl -X POST -d "grant_type=password&username=
<user_name>&password=<password>" -u"<client_id>:<client_secret>"
http://localhost:8000/o/token/
{"access_token": "fFySxhVjOroIJkD0IuEXr5WIhwdXg6", "expires_in":
36000, "token_type": "Bearer", "scope": "read write groups",
"refresh_token": "14vhyaCZbdLtu7sq8gTcFpm3ro9YxH"}
But if I request an access token from absolutely the same application deployed at AWS Elasticbeanstalk, I get 'invalid client' error:
dev#devComp:$ curl -X POST -d "grant_type=password&username=
<user_name>&password=<password>" -u"<client_id>:<client_secret>"
http://my-eb-prefix.us-west-1.elasticbeanstalk.com/o/token/
{"error": "invalid_client"}
Please advise me what to do to get rid of this error and normally request access tokens from django app deployed at AWS.
After some research, I can now give the answer myself:
I had to add one more command to my python.config in .ebextensions folder:
...
container_commands:
...
03wsgipass:
command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
After that, AWS allows incoming requests to pass authorization, and I get the response without an error.
I was also facing the same problem.
This worked for me:
curl -X POST -d "grant_type=password&username=<your-username>&password=<your-password>&client_id=<your-client id>&client_secret=<your-client secret>" http://your-domain/o/token/
{"access_token": "0BVfgujhdglxC7OHFh0we7gprlfr1Xk", "scope": "read write", "token_type": "Bearer", "expires_in": 36000, "refresh_token": "AwffMPzNXvghlkjhs8dpXk7gbhhjhljlldfE2nI"}

Postman: Newman collection runner unable to send form url-encoded parameters in body with calls

In postman to send credentials to setup login in the body section x-www-form-ulrencoded. This works absolutely fine.
After exporting this script in newman collection runner, this does not work.
Following is the output:
-------------------------------------------------------------------------------------------
401 3361ms Login Call [POST] https://<url>/login
------------------------------------------------------------
Request headers:
{
"content-type": "application/x-www-form-urlencoded",
"host": "<url>",
"accept-encoding": "gzip, deflate",
"content-length": 0
}
Request data:
{
"userid": "user",
"password": "pswd"
}
------------------------------------------------------------
Response headers:
{
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"x-content-type-options": "nosniff",
"date": "...",
"cache-control": "no-cache",
"content-length": "120",
"x-xss-protection": "1; mode=block",
"connection": "close",
"accept-ranges": "bytes"
}
Response body:
{"errorCode":"401","errorMessage":"Login failed, please check the credentials","errorDescription":"API Request Failure"}
Also, when i generate curl code from postman i don't see the user/pswd headers attached:
curl -X POST \
https://<url>/login \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'postman-token: 5b04e538-498c-9e43-2be9-8523073260f9'
Using Postman Chrome app:
Postman for Chrome
Version 5.0.2
win / x86-64
Chrome 59.0.3071.115
So the issue over here is the version of Newman installed.
So I got the latest version:
//to install
npm install -g newman
//needed to use Newman.run instead of Newman.execute
newman run c:\s -e c:\env --reporters cli,json --reporter-json-export c:\out.json -k
//-k was required to bypass ssl security issues.