How to enter this http POST request into Postman? - postman

Sorry for an ignorant question. I'd like to use Postman to sent a POST request given by a framework which suggests:
http POST
https://api.telemetry.confluent.cloud/v2/metrics/cloud/query \
aggregations:='[{"metric":"io.confluent.kafka.server/sent_bytes"}]' \
filter:='{"op":"AND","filters":[{"field":"resource.kafka.id","op":"EQ","value":"zzz-12345"},{"field":"metric.topic","op":"EQ","value":"demo-topic-1"}]}' \
granularity=PT1M \
intervals:='["2021-08-14T18:37:00-04:00/2021-08-14T19:37:00-04:00"]' \
limit=1000 \
Authorization:"Basic base64(<API_KEY>:<API_SECRET>)"
Reading quickly through Postman doc Sending your first request. I can't figure out what to input in the UI of the Postman' POST request to reproduce the above instructions.
I actually could get the result using curl b/c the framework also gives a curl command. The point here is to learn how to use Postman.
Thanks very much for any help.

Related

Getting "invalid_payload" and 400 response when trying to send data to a slack channel through Postman

I'm using postman to trigger a message using the slack channel's incoming webhook url. I tried the following curl and it works:
curl --location --request POST 'https://hooks.slack.com/services/T026NT2D4/B02UM3G1D35' \
--header 'Content-type: application/json' \
--data-raw '{"text":"Hello world"}'
I need to send aws S3's presigned URL to this channel but no matter how I try sending the data, I always get invalid_payload as the response. I tried sending it as Json message, Raw text and even tried x-www-form-urlencoded. Nothing seems to work.
I need some implementation example for this. Also, I'll be using spring boot to generate and send the message, so any resources on beautifying the message would be really helpful.
I've seen examples where the slack channel has some text and "more" option, which, upon clicking downloads a file(I'm assuming this "more" is a hyperlink of the presigned URL)
EDIT:
I was trying out a few more stuff. When I send the Json with only one field and specifically naming that filed "text", I'm able to send the message.
So my payload looked liked this:
{
"text": "*Presigned URL*"
}
The headers had Content-type as application/json.
Even if I changed "text" to "Message" I'm getting a 400 response. Is that what no_text means? that there is no "text" field in the payload
Just putting it here in case someone needs this.
That is the case, a "text" field should be there in the json message.
Link to slack guide
Found this implementation in case anyone wants to use slack SDK in spring boot : Implementation Link

How to authorize when sending email with Mailgun?

I would like to send email with Mailgun via Postman. I write my Private API key in all different way in the Authorization section in Postman. But it always refuse me, got a HTTP 401.
What is wrong?
I tried send via CURL as tutorial suggest, but is fails also:
https://documentation.mailgun.com/en/latest/quickstart-sending.html#send-via-api
kukodajanos#Kukoda-MacBook-Pro-2 ~ % curl -s --user 'api:b3c5...' \
https://api.mailgun.net/v3/mg.tiket.hu/messages \
-F from='janosontech#gmail.com' \
-F to=kukodajanos#icloud.com \
-F subject='Hello' \
-F text='Testing some Mailgun awesomeness!'
Forbidden%
Basic authentication (as in your first screenshot) should work. (Also make sure, you don't have any spaces, newlines or other wrong characters included in your token)
Are you using your primary API key or a sending key specifically for that domain? If the first, try creating a sending key for you domain. If the latter, try recreating the key.

Connect to elasticsearch in AWS using key credentials

I'm trying to post a request using curl to my es cluster in AWS using my accessKey and secretKey. I have successfully done this through postman (details here) where you can specify AWS credentials but I would like to make this work with curl. Postman can auto-generate your curl request for you but all I get are errors.
This is the generated curl request along with the response
curl -X GET \
https://search-00000000000001.eu-west-1.es.amazonaws.com/_cat/indices \
-H 'Authorization: AWS4-HMAC-SHA256 Credential=11111111111111111111/20181119/eu-west-1/es/aws4_request, SignedHeaders=cache-control;content-type;host;postman-token;x-amz-date, Signature=11111111116401882398f46011f14fdb9d55e012a4fb912706d67c1111111111' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: search-00000000000001.eu-west-1.es.amazonaws.com' \
-H 'Postman-Token: 00000000-0000-4001-8006-9291e208a000' \
-H 'X-Amz-Date: 20181119T220000Z' \
-H 'cache-control: no-cache'
{"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."}%
IDs have been changed to protect the innocent.
I have checked all my keys and region, and like i said this works through postman. Is it possible to access this AWS service using my keys through curl?
This is quite a long rabbit hole. Thanks to Adam for the comment that sent me in the correct direction. The link https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/ really helps you understand what you need to do.
I've since found a script that follows the signing requests method outlined above. It runs in bash and whilst it is not written for use with elasticsearch requests it can be used for them.
https://github.com/riboseinc/aws-authenticating-secgroup-scripts many thanks to https://www.ribose.com for putting this on github.
If your host contains ':443' remove it and try again.
This worked for me.
"My initial problem: If I access it with Postman using the same url, I get the same error, but removing the ‘:443/’, it works fine, so it’s nothing wrong with the key and secret I’m using."

How to upload files(png and txt files) using raw in POSTMAN?

The postman works in the below format to upload an attachment.
set method type to POST.
Then select Body -> form-data -> Enter your parameter name
and on right side next to value column, there will be dropdown "text, file", select File. choose your image file and post it:
I succeed with form-data, how do achieve via RAW text or Json because the image which is uploaded is dynamic.The image and txt file is stored in my local.
I am trying to upload png and .txt file to JIRA Rest endpoint(Subtask). My goal is create subtask, once subtask is created add attachment to it, attachment can be dynamic.
curl -X POST \
https://host/rest/api/3/issue/pos-14108/attachments \
-H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-H 'Postman-Token: c2b02ef1-4b81-4e8e-bb02-fb697bb2680e,1c20aa55-27c5-44c3-9f08-7efc41f25576' \
-H 'X-Atlassian-Token: no-check' \
-H 'cache-control: no-cache,no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F file=#/Users/nmane/Desktop/harry.png
According to this article on the Jira forums, to add an attachment, you should do the following:
curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=#{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments
according to Using curl to upload POST data with files
That fits with your comments and experiences, as far as I can tell.
I have not encountered anything about attaching files to a "raw" JSON request. The only way to do something like that would be to base 64 encode it (see Is it possible to attach file in POST Json? ) but I do not think that the Jira REST API supports it.
I hope that I have understood your issue correctly. if not, and you actually (for some reason) want to run everything from postman/newman, please update your question.

How do I use the --header option to send cookies with Siege?

I have just started to use Siege to do load/stressing test on a new web server. I am trying to test on my most resource/performance heavy script, but the script requires cookies. What is the proper format for using the --header option in siege?
I have tried this with no luck:
siege --header="Set-Cookie: PHPSESSID=--COOKIE--; iptoken=--COOKIE--" http://www.myurl.com/script.php,
There is no documentation on this that I could find, so any ideas/suggestions would be appreciated.
The answer is to use --header="Cookie: --COOKIE_DATA--" (ref. wiki.wsmoak.net/cgi-bin/wiki.pl?Siege).