curl command in Postman - api

I developed POST api and tried to post via POSTMAN
I create following POST method.
But I send this data, empty data was send to server.
When I check code. the curl method was line breaked.
I guess this is the reason why the empty data was sent.
How can I fix it and send body ?
The following command send body data.
curl --data "loginId=hikaru&password=test" http://localhost:3000/user
line break is difference between them.
Thank you.

As you stated in the comment you like to have the curl generated with
--data "loginId=hikaru&password=test"
Even though this might look like form-data it is a a raw body. To change the curl command generated follow these steps:
change the the body type from form-data to raw
enter loginId=hikaru&password=test as the body then Postman will generate the curl command you like to see

Related

JMeter testing for the url which contains # as path param

I have REST API which takes the username as a path parameter like this - app/users/{username}.
As per the business requirement, the username can be an email address as well.
Application is developed and we can test using postman, curl etc., by encoding the URL. But when we use JMeter to test the same API,
We are not able to send the encoded URL using JMeter. To demonstrate the problem, I created a webhook site(https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter)
and requested as below.
"GET https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter"
This resulted in a webhook as below
"https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter#jmeter"
But we want the output like below which we could accomplish by postman or curl.
curl --location --request GET 'https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter'
Please help how I need to prepare my JMeter script which produce the same output as above (in curl)
I cannot reproduce your issue using latest JMeter 5.4
Not sure what does your "webhook" do, however in a sniffer tool like Wireshark request paths are exactly the same for curl and JMeter and no %40 doesn't get decoded into #
If you're capable of sending your request successfully via curl or postman you should be able to record it using HTTP(S) Test Script Recorder - this way you will get appropriate JMeter configuration.

Sending push using countly API

I am trying to send a notification using the countly API ,
I found this in the documentation :
curl --request POST \ --url 'https://try.count.ly/i/pushes/prepare?args.apps=args.apps&args.platforms=args.platforms&args=args&api_key=api_key'
It says that i have to provide args which is a JSON object as string with future message data.
They don't provide any clear documentation about how should this arguments be
Any help would be appreciated
Throughout the system Countly expects a stringified JSON object in args parameter. You can look at how it works by sending a message from dashboard and looking at requests in Chrome developer tools, for example. But here we go:
curl --form 'args={"apps":["57fb679323b5388e28e2c37e"],"platforms":["a"],"tz":false,"test":false}' http://HOST/i/pushes/prepare?api_key=API_KEY
and then
curl --form 'args={"apps":["57fb679323b5388e28e2c37e"],"platforms":["a"],"tz":false,"test":false,"_id":"58cb862e2a16277d4501d787","type":"message","messagePerLocale":{"default":"Message text"},"locales":[{"value":"default","title":"Default","count":1062,"percent":100},{"value":"en","title":"English","count":296,"percent":28},{"value":"ja","title":"Japanese","count":166,"percent":16},{"value":"it","title":"Italian","count":152,"percent":14},{"value":"fr","title":"French","count":152,"percent":14},{"value":"de","title":"German","count":149,"percent":14},{"value":"ko","title":"Korean","count":147,"percent":14}],"sound":"default","source":"dash","date":"2017-03-24T07:00:00.000Z"}' http://HOST/i/pushes/create?api_key=API_KEY
You can also omit first request as described in documentation.

Confluence REST API Authorization Failure

I am trying to use the Confluence REST API to create a page. I am using the curl example off of the documentation found HERE. Every time I try to run a terminal command using this curl I get a response that says 'HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED'. I see that someone else had a similar issue regarding their C# code, but there was never a resolution given. Hopefully someone with experience will be able to tell me what I am doing wrong. My curl is listed below with the sensitive parts replaced in <> format.
curl -u <USER>:<PASSWORD> -X POST -H 'Content-Type: application/json' -d'{"type":"page","title":"new page","space":{"key":"<PAGEKEY>"},"body":{"storage":{"value":"<p>This is a new page</p>","representation":"storage"}}}' https://<SERVER>/wiki/confluence/rest/api/content/ | python -mjson.tool
I was finally able to resolve this. Through a combination of the answer here How to create new page in Confluence using their REST API? and using a login that had the appropriate permissions.

API Post Data to Middleware

Anyone know how I can test posting data to this url? I was given the link by the IT supervisor and trying to have the data posted to the following link by submitting the following form. He said it would accept anything I send it
Could could do this via curl:
curl -X POST -d "data=anything_i_send_it" http://powersource.braindongle.com/lead-manager/lead/new/omgpost/sessions/
Or using another HTTP tool like Hurl.it
Or using a Chrome extension like Postman or REST Console.
Advanced Rest Client is an easy way to do it. It's a free chrome extension that can form http requests with data.

Heroku application log streaming

I'm trying to use the new Heroku api to stream the logs of my application using curl:
Here is what is said in the doc (https://devcenter.heroku.com/articles/platform-api-reference#app)
Streaming is performed by doing an HTTP GET method on the provided logplex url and retrieving log lines utilizing chunked encoding.
So first I retrieve the logplex url:
curl -X POST https://api.heroku.com/apps/my-app/log-sessions \
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization:XXX" -v
Then I get something like this in the response:
"logplex_url":"https://logplex.heroku.com/sessions/abcdef-079b-4264-a83c-031feb31bfc2?srv=132456798"
So I make another curl call:
curl -X GET "https://logplex.heroku.com/sessions/abcdef-8a7e-442f-a164-4c64e845b62d?srv=123456798" -H "Transfer-Encoding: chunked"
I got a persistent connection but nothing comes...
If I don't specify the Transfer-Encoding header, I get the logs, but the connection close.
Is it really possible to stream the logs, like it's specified in the reference ?
It is possible, unfortunately I was mistaken in writing it and it is not chunked encoding as I believed. We do use this interface in the CLI and in log2viz, but it is unfortunately not standard http per se.
Basically you should do a normal HTTP request and read back the HTTP response headers. Given the headers returned you would then normally read from the socket until you got a zero length read, at which point you can assume you are done and finish up. In the logplex case we are reticent to block (perhaps indefinitely) so we go ahead and return an empty read. Then we just expect that when you are done you can simply close the socket.
Unfortunately I was unable to figure out how to do this with cURL. But I can point to the examples in our open source where we tackle this, and hopefully that will help.
toolbelt - https://github.com/heroku/heroku/blob/master/lib/heroku/client.rb#L482
log2viz - https://github.com/heroku/log2viz/blob/master/app.rb#L153
Hopefully that helps clarify the current situation at least, I'll try to update the docs to reflect this. Thanks for the detailed report and let me know if you have additional questions I can help with.