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
Related
I'm trying to link a ADO Requirement work item to a ADO Test Case work item. I'm making this call:
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{{\"op\": \"test\", \"path\": \"/rev\",\"value\": 3 },{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":\"{\"rel\": \"System.LinkTypes.Dependency-forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0
as per: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-7.1#add-a-link
But I'm having this error:
{"$id":"1","innerException":null,"message":"You must pass a valid patch document in the body of the request.","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common","typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000}
I found my answer, the JSON was badly parse. I used a online JSON linter to fix it. https://jsonlint.com/
curl -u :********** -X PATCH -H "Content-Type: application/json-patch+json" -H "Accept: application/json-patch+json" -d "[{\"op\": \"add\", \"path\": \"/relations/-\", \"value\":{\"rel\": \"Microsoft.VSTS.Common.TestedBy-Forward\",\"url\": \"https://***.***.com/{Organisation}/_apis/wit/workItems/{ID}\",\"attributes\": {\"comment\": \"Making a new link for the dependency\"}}}]" https://***.***.com/{Organisation}/{Project}/_apis/wit/workItems/{ID}?api-version=6.0
I am trying to import existing json file using HTTP API, but the 'curl' command throwing the error.
I am using the below command to import existing json file,
curl --user admin:admin "http://localhost:3000/api/dashboards/db" -X POST -H "Content-Type:application/json;charset=UTF-8" --data-binary #/u04/sys_monitor/my_Metrics.json
If i run the above command, it is throwing the error like "[{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]"
I tried to run the below command,
curl --fail --insecure --user admin:admin --request "POST" "http://localhost:3000/api/dashboards/db" --header "Content-Type: application/json" --data-binary #/u04/sys_monitor/my_Metrics.json
For the above command execution i am getting the error like,
curl: (22) The requested URL returned error: 422 Unprocessable Entity
Where i am doing wrong, kindly assist me,
The below comment is working but not updated the dashboard in grafana,
curl --user admin:admin -vvv "http://localhost:3000/api/dashboards/db" -X POST -d #My_Metrics.json -H 'Content-Type: application/json'
I'm trying to find a way to add a label to a GitHub issue using the API. After checking the API documentation I tried the following curl request:
curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H \
"Accept: application/vnd.github.symmetra-preview+json" \
-d #label.json https://api.github.com/repos/CHSUNSONG/star-platform/issues/11
label.json contains:
["submitted"]
However, I got the following response:
{
"message": "Invalid request.\n\nFor 'links/1/schema', [\"submitted\"] is not an object.",
"documentation_url": "https://developer.github.com/v3/issues/#edit-an-issue"
}
Why isn't this working and how can I fix it?
You're POSTing to the wrong URL. Add /labels onto the end:
curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H \
"Accept: application/vnd.github.symmetra-preview+json" \
-d #label.json \
https://api.github.com/repos/CHSUNSONG/star-platform/issues/11/labels
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[#]}"
I wrote this curl command which doesn't seem to work.
curl -H "Content-Type: application/json" -X PUT "Authorization: Bearer {token}" -d "{"login":"user1","password":"xxx"}" https://localhost:8443/users/user1 -k
I tried to change quotation marks but it doesn't work either. All I got is
curl: (6) Could not resolve host: Authorization
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}
The Authorization works fine though. I'm sure the token is correct.
The -H flag is missing in front of the Authorization header.
Try
curl -H "Content-Type: application/json" -H "Authorization: Bearer {token}" \
-X PUT -d '{"login":"user1","password":"xxx"}' \
https://localhost:8443/users/user1 -k
Because that was missing it was not seeing that as a header, but part of the request URL.
To test, I decode with this in PHP:
var_dump(json_decode(stream_get_contents(fopen('php://input', 'r'))));