How to make a manual commit by using REST proxy - apache-kafka

What I'm trying to do is make a manual commit using the Kafka REST proxy. I'm trying to use this code:
curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" -H "Accept: application/vnd.kafka.v2+json" \
--data '{"format": "json", "auto.commit.enable": "false", "auto.offset.reset": "earliest"}' \
http://localhost:8082/consumers/test_consumer
// Subscribe
curl -X POST -H "Content-Type: application/vnd.kafka.v2+json" --data '{"topics":["test.sap.pn.add"]}' \
http://localhost:8082/consumers/test_consumer/instances/rest-consumer-587fceb2-2f2c-404f-b71d-c3eb3c678bac/subscription
// Get data
curl -X GET -H "Accept: application/vnd.kafka.json.v2+json" \
http://localhost:8082/consumers/test_consumer/instances/rest-consumer-587fceb2-2f2c-404f-b71d-c3eb3c678bac/records
// commit
curl -X POST -H "Accept: application/vnd.kafka.v1+json, application/vnd.kafka+json, application/json" \
http://localhost:8082/consumers/test_consumer/instances/rest-consumer-587fceb2-2f2c-404f-b71d-c3eb3c678bac/offsets
Which then returns: {"error_code":40403,"message":"Consumer instance not found."}
What am I doing wrong?

Related

Remove 'accept: */*' (header) from curl commands generated by Swagger Editor?

I'm using the online Swagger Editor. When I send a request using "try it out", it generates this curl command:
curl -X 'POST' \
'https://coo.amazonaws.com/' \
-H 'accept: */*' \ # Extra one
-H 'X-Amz-Target: send by me ' \
-H 'Authorization: Bearer "token"' \
-H 'Content-Type: application.1' \
-d '{
"AuthParameters": {
"USERNAME": "John",
"PASSWORD": "James"
},
Remove-H 'accept: */*' from header in the curl command.

Geoserver: REST create WMTSLayers

Under Geoserver, How do we create the WMTSLayer once the WMTSStore is establish via REST API ?
Trying to follow the swagger documentation under here,
https://docs.geoserver.org/latest/en/api/#1.0.0/layers.yaml
But can't find the correct url to work for it. Get 404 when I try this using curl
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspaceName}/wmtsstores/{wmststoreName}/wmtslayers -H "accept: application/json" -H "content-type: application/json" -d "{\"featureType\":{\"name\":\"World_Imagery\"}}"
Also looked under here,
https://docs.geoserver.org/latest/en/api/#1.0.0/wmtslayers.yaml
And tried below url for it. Get 500 when I try this using curl
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspace}/wmtsstores/{wmtsstore}/layers -H "accept: application/json" -H "content-type: application/json" -d "{\"featureType\":{\"name\":\"World_Imagery\"}}"
Found it, need to pass wmtsLayer
curl -v -u admin:geoserver -X POST http://localhost:8085/geoserver-cloud/rest/workspaces/{workspace}/wmtsstores/{wmtsstore}/layers -H "accept: application/json" -H "content-type: application/json" -d "{ \"wmtsLayer\": { \"name\": \"NatGeo_World_Map\" } }"

fiware-orion notification failure with https

I have a problem with my Fiware-Orion (2.1.0) notifications with Quantum-Leap for managing time-series datas (related to that component quantumleap ).
Both are within Docker containers and using HTTPS.
In orion I create the subscription for Quantum-Leap. It works.
And when I create or update an entity, Orion send me an 200 OK response and the notification never reach Quantum-Leap.
I have nothing in logs.
When I make a request directly to an endpoint using Curl or Postman, the request works. Requests using Orion always fail.
Here is the curl used by Postman to QuantmLeap that works.
curl -X POST \
https://ql1-dev.mydomain.com/v2/notify \
-H 'Accept: application/json' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Fiware-Service: svctestnca' \
-H 'Fiware-ServicePath: /svcpath/testnca' \
-H 'Host: ql1-dev.intranice.ville-nice.fr' \
-H 'Ngsiv2-AttrsFormat: normalized' \
-H 'Postman-Token: 76255023-47e3-44c5-8abf-d184a1dd77f0,adaa68e0-abf4-4fea-855d-39c3469ba1d4' \
-H 'User-Agent: PostmanRuntime/7.11.0' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \
-H 'content-length: 279' \
-d '{
"subscriptionId": "5c62b47f132e5369012c4726",
"data": [
{
"id": "Testnca:testnca1",
"type": "Testnca",
"dateObserved": {
"type": "DateTime",
"value": "2019-02-04T16:19:22.00Z"
},
"mesure": {
"type": "Number",
"value": 2.0
}
}
]
}'
Thanks for help and advices
I tried to use HAProxy like in this Stack-Overfow question and it solves my problem.
Orion always add the port number to my request and I missed that element.
Thank you all and especially StephaneRouxNCA

Can't post in a specific Yammer's group

I'm doing a curl to send a POST in my group, and it doesn't works, it posts on the All Company Network even if I sent the group_id.
curl -H "Accept: application/json" -H "Content-type: application/json" -H "Authorization: Bearer OAUTHTOKENHERE" -X POST -d '{"activity":{"actor":{"email":"MYEMAIL"},"action":"create"}}' https://www.yammer.com/api/v1/messages.json?body=TestingfromYammersAPI&group_id=GROUPID
I'm writing the right group_id, and still not reading that argument.
Does anyone has this problem too?
Yammer's API docs:
https://developer.yammer.com/docs/messages-json-post
The problem was that I wasn't quoting the URL -___-
Working code:
curl -H 'accept: application/json' -H 'authorization: Bearer OAUTHTOKENHERE' -H 'content-type: application/json' -X POST -d ' ' 'https://www.yammer.com/api/v1/messages.json?body=MESSAGE_HERE&group_id=GROUP_ID'

Box -> View API -> Can not authenticate to create session

in this site :https://developers.box.com/view/
I do follow the instruction in the example (use Postman or curl)
curl https://view-api.box.com/1/sessions \
-H "Authorization: Token YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"document_id": "ABC123"}' \
-X POST
YOUR_API_KEY is replaced by my api key
ABC123 is replaced by a my pdf file.
But I got result: {"message": "Unsupported media type 'application/json, application/x-www-form-urlencoded' in request.", "type": "error", "request_id": "1f3d91c9489247579c78e7ceaa5e67c8"}
Please help me.
Thank you
It looks like there is an issue with the spaces after your \ characters. If you try:
curl https://view-api.box.com/1/sessions \
-H "Authorization: Token APIKEY" \
-H "Content-Type: application/json" \
-d '{"document_id": "DOCID"}' \
-X POST
It should work.