Using the sample code from Camel in github in 1 I am getting 404 instead of 405.
This is a summary of the code in 1
rest("/provider").description("Provider rest service").consumes("application/json").produces("application/json").get("/{id}").description("Find provider by id").outType(Provider.class).to("bean:providerService?method=getProvider(${header.id})");
When I send this I am getting the right answer.
curl -X GET -H "Accept: application/json" http://localhost:8080/providerservice/rest/provider/123
When I send this I am getting 404. I am expecting 405
curl -X POST -H "Accept: application/json" http://localhost:8080/providerservice/rest/provider/123
I appreciate any help!!
Not sure if it was you whom logged a JIRA ticket about this: https://issues.apache.org/jira/browse/CAMEL-12050
But this functionality has now been implemented and will be in the upcoming Apache Camel 2.21.0 release onwards.
Related
I'm newbie on this so I would like your help, according to CrazyCall docs I want to test those code examples in terminal using CURL, for example this one:
GET /api/v1/users HTTP/1.1
x-api-token: your-secret-api-key
Account: your-account-hash.crazycall.com
Host: api.crazycall.com
I tried to convert to curl and execute like this:
curl -XGET -H 'x-api-token: mdsRFGRV23XXXXXXX' -H 'Account: lopDOPLSVXXXX.crazycall.com' -H 'Host: api.crazycall.com' /api/v1/users
But it shows me a message <url> malformed
I also added "Content-type: application/json" header but it's still the same.
How can I fix it?
Prepand the protocol and domain (https://api.crazycall.com) to your path (/api/v1/users):
curl -X GET -H 'x-api-token: mdsRFGRV23XXXXXXX' -H 'Account: lopDOPLSVXXXX.crazycall.com' -H 'Host: api.crazycall.com' https://api.crazycall.com/api/v1/users
I'm using successfully the WordPress 4.7 REST API in this way:
curl -H "Authorization: Basic mykey" -X POST --data-urlencode "title=Something" www.myhost.com/wp-json/wp/v2/posts/770
The example in the new docs suggests:
curl -X POST http://demo.wp-api.org/wp-json -d '{"title":"My New Title"}'
which obvious is a wrong endpoint. Adapting to
curl -H "Authorization: Basic mykey" -X POST www.myhost.com/wp-json/wp/v2/posts/770 --data-urlencode '{"title":"My New Title"}'
does not change the title but simply returns the post as JSON
Any idea?
Came over my own question, which I did resolve a long time ago. Just if someone struggles with this too.
First of course, posting data with curl requires the -d option an not the --data-urlencode. Second, the REST endpoint needs to know the type of data. Here JSON. So setting the correct Content Type is essential.
This is a complete example:
curl -H "Authorization: Basic mykey>" -H "Content-Type: application/json" -X POST -d '{"title":"Something"}' www.myhost.com/wp-json/wp/v2/posts/770
I am trying to use an HTTP POST command directly to a D-Link DCS-932L camera (I have one camera on F/W 1.12 and another on 1.14, if that helps). I keep getting the 404 File Not Found error.
Running Fiddler, I've turned on motion in the browser and seen the following request:
POST /setSystemMotion HTTP/1.1
Syntax is
ReplySuccessPage=motion.htm&ReplyErrorPage=motion.htm&MotionDetectionEnable=1&MotionDetectionScheduleDay=0&MotionDetectionScheduleMode=0&MotionDetectionSensitivity=45&ConfigSystemMotion=Save
If I try to turn on motion using an HTTP POST command via the Chrome Extension Postman using the exact same request and syntax I get
<html><body><h2>Error: File Not Found</h2>
<p>getfile: Cannot open URL(/etc_ro/web/setform/setSystemMotion,No such file or directory)</p></body></html>
It seems that the camera's server has decided to route my ./setSystemMotion to this ./etc_ro/web/setform folder. I'm happy to provide more details, but can anybody shed some light on what might cause that change?
Thanks!
I've the same issue.
resolved with this curl command taken from the below forum
curl "http://<IP>/setSystemMotion" -H "Host: <IP>" \
-H "Referer: http://<IP>/setSystemMotion" -H "Authorization: Basic <AuthCode>" \
-H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1" \
--data "ReplySuccessPage=motion.htm&ReplyErrorPage=motion.htm&MotionDetectionEnable=1&MotionDetectionScheduleDay=127&MotionDetectionScheduleMode=1&MotionDetectionScheduleTimeStart=07"%"3A10"%"3A00&MotionDetectionScheduleTimeStop=18"%"3A50"%"3A00&MotionDetectionSensitivity=70&ConfigSystemMotion=Save"
https://www.developpez.net/forums/d1424172/systemes/hardware/achat-conseils/peripheriques/camera-ip-commandes-url-api-dlink-dcs-932l/#post8858654
I'm using openam OAuth/OpenID for user authentication. As mentioned in the documentations, I could get SSOTokenID as a JSON object by making following HTTP request.
curl -X POST -H "X-OpenAM-Username: demo" -H "X-OpenAM-Password: changeit" -H "Content-Type: application/json" -d '' -k -v https://openam.example.com:8443/openam/json/authenticate?realm=/
Instead of that, I want to get SSOTokenID as the Set-Cookie header value of the HTTP response. Are there anyway that i can do it?
Assuming you are only using an authentication module that accepts a NameCallback and PasswordCallback (as you used in your example), then you can just use the legacy UI zero-page login , you need to disable XUI though
Using your example
curl -X POST -d 'IDToken1=demo&IDToken2=changeit' -k -v https://openam.example.com:8443/openam/UI/Login?realm=/
I'm following this tutorial https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/#send_a_request_from_the_command_line_for_fcm_to_push_a_message
I did everything as is instructed there so far. However when I do a curl request I get back
{"multicast_id":6771552758811002436,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
I checked it billion times I have put correct senderId in my manifest.json in "gcm_sender_id"
So why would I get such error?
Here are some more details.
In the tutorial it says to get the keys from FCM console in cloud messaging
This is how my manifest.json looks like
{
"name":"Push Notifications codelab",
"gcm_sender_id":"773185791049"
}
And this is how I send the request
curl --header "Authorization: key=AIzaSyCQHb2t8c3N255bH_CVmGych5QcNntFxYg" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"APA91bE4RJ7_9m2eJ_zlg1F90bLjVX8ctVpCBN24ElAXF--4wS_nnxg4LzkbJWeTe-peMN_StmOaQTEoGeCCNZE5Mssux3T-KbfGRVmRWzeQZM8opfUyv7FVjI9iEfETHG3O7i1qkIb-\"]}"