Activemq REST without body= - rest

Is there a way to POST to an ActiveMQ topic without requiring body= ?
e.g. instead of this:
curl -u test:test -d "body=message" http://server:8161/api/message/testtopic?type=topic
use this:
curl -u test:test -d "message" http://server:8161/api/message/testtopic?type=topic

It turns out that specifying the Content-Type allows you to omit body=
curl -u test:test -d "message" -H "Content-Type: text/plain" http://server:8161/api/message/testtopic?type=topic

Related

Correcting a simple malformed CURL request

I have a fairly straightforward curl GET request to a server that has a functioning endpoint but which is giving me a 400 error. I'm honestly not sure what's causing the error.
Here's the request:
curl -v -g -X GET "https://pokemon.server.com/api/set_data?scan_next=true&instance=City%20Downtown&coords='[{"lat":120,"lon":45}]'" -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:application/json' -u 'user:password'
The API spec is here: https://github.com/RealDeviceMap/RealDeviceMap/wiki/7.-API-Calls
And I know it's not an authentication issue because this request works
curl -v -X GET 'https://pokemon.server.com/api/set_data?reload_instances=true' -H 'Accept:application/json' -u 'user:password'

MarkLogic ingest JSON from external API

I am using Marklogic 9 and try to ingest data from external source into MarkLogic. I made an REST API on port 8031. When I try to execute the following curl command:
curl --anyauth --user admin:admin -i -X POST -d https://services7.arcgis.com/21GdwfcLrnTpiju8/arcgis/rest/services/Geluidsbelasting/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json
-H "Content-type: application/json" -H "Accept: application/json" \
'http://localhost:8031
After executing this statement I receive the error:
Curl: URL is not specified
Can you please help me out!
Many thanks
Erik
Your -d parameter has special characters that are not escaped. Try putting quotes around your -d url. It will prevent your command from getting truncated and misinterpreted at & signs..
HTH!

How to send a curl request to timekit.io API

I am trying to follow the documentation from timekit.io. I am attempting to do something as simple as send a curl request to do basic authentication as seen in this section of the docs. I have replaced the Timekit-App:name-of-app with the name of my app which I found in the app-settings of my timekit account. I also replaced the email & password with the one's I use to login into my account.
I simply copied and pasted the curl command as is into my terminal and I get a response that says {"error":"Content-type should be json!"} I am not sure if I am not supposed to copy and paste it as is, or what I may be doing wrong, but my understanding is I am supposed to get a json response with a email and a api token among some other data.
Here is my curl command.
curl -X POST \
-H 'Timekit-App: jl-fit' \
-d '{
"email": "email#email.com",
"password": "password"
}' \
https://api.timekit.io/v2/auth
Looks like you have discovered a bug in their docs/examples.
The API you're connecting to expects JSON content type, but curl by default (for POSTing data) uses application/x-www-form-urlencoded. You can fix it by adding the header field explicitly with: -H 'Content-Type: application/json'.
Also, when you use the -d/--data option, method defaults to POST, so it doesn't have to be specified explicitly.
All put together, this should work:
curl \
-H 'Content-Type: application/json' \
-H 'Timekit-App: jl-fit' \
-d '{"email": "email#email.com", "password": "password"}' \
"https://api.timekit.io/v2/auth"
When having multiple arguments, it can be convenient to keep them in an array (no need to escape newlines). For example:
args=(
-H 'Content-Type: application/json'
-H 'Timekit-App: jl-fit'
-d '{"email": "email#email.com", "password": "password"}'
"https://api.timekit.io/v2/auth"
)
curl "${args[#]}"

Create topic in Message-Hub via curl command

I am trying to create a topic in Message-Hub using a curl command.
I followed this yaml: https://github.com/ibm-messaging/message-hub-docs/blob/master/kafka-administration-api/KafkaTopicManagement.yaml
I'm getting HTTP 405 Method Not Allowed when running the following:
curl -X POST --tlsv1.2 -vk -H "Content-Type: application/vnd.kafka.binary.v1+json" -H "X-Auth-Token: apikey from the environment variable of my app" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/topics -d "{ \"TopicCreateParam\" { \"name\": \"my.test\" }}"
Thanks for any help.
#jd76 three problems here:
your URL is missing the /admin/ path
your content-type should just be plain json
TopicCreateParam is just the name of the type in the swagger yml.
Try:
curl -H "Content-Type: application/json" -H "X-Auth-Token: apikey from the environment variable of my app" -d "{ \"name\": \"my.test\" }" https://kafka-rest-prod01.messagehub.services.us-south.bluemix.net/admin/topics

Calling an PingAccess APIs from Powershell

I am trying to call PingAccess APIs to configure my PingAccess.
I am new to using APIs to do this, and have a question.
I am trying to use CURL to the API .
curl -k -u Administrator:dummypsswd -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v
When I run this I get the following error.
I still dont know why am I unauthorized. Any help is appreciated.
When you have special characters in your password you'll need to enclose the username/password tuple in double quotes:
curl -k -u "Administrator:dummypsswdwithspecialcharslike&&" -H "X-Xsrf-Header: PingAccess" -H "Content-Type: application/json" -d '{"alias":"PLACEHOLDER_STAR_MINGLE","fileData": [[System.IO.File]::ReadAllBytes("C:\test.pfx")],"password": "1234"}' https://localhost:9000/pa-admin-api/v1/keyPairs/import -v