While using
curl -3 -u \
"f07c43a6-bb0a-4bb7-a1eb-a368db272212:e2cf19c3-6636-4712-bbe8-26b7c1ac9c09" \
-v -H "Accept: application/json" -H "Content-type: application/json" \
-X POST -d '{"message": {"alert":"Hello AeroGear", "badge":1}}' \
https://aerogear-html5.rhcloud.com/rest/sender
to push notification
I am getting 401 unauthorised request.Unable to figure out how to authenticate?
Make sure your authorization parameters(through -u) are valid and also make sure you are using the correct credential for the service you are trying to access.
Also, if you are from windows(for linux its ok) then wrap the post parameters with double quotes(") Instead of single(').
-d "{\"message\": {\"alert\":\"Hello AeroGear\", \"badge\":1}}"
Going to this link https://aerogear-html5.rhcloud.com, produces a website not available
Is there a specific tutorial you used to get that curl command?
Related
Need to send by shellscript every new string in Android logcat by curl POST command to server. Connected to Android by ADB.
I was trying this things:
#logcat com.mm.en:I -e "chat"| tee /sdcard/Pictures/out.txt
It makes a file, and write every new string to it.
Next i was trying:
#curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://nnnn.ru/test/testprint.php -G -d '{"id":"IDVALUE","name":"Mike"}'
It is also work.
But when i trying to combine it by guide, it doesnt work:
#logcat com.mm.en:I -e "chat"| curl -H 'Content-Type: application/json' http://nnnn.ru/test/testprint.php -d #-
Where i`m wrong?
I am working on Android application using ESP32. I want a system, where, when I press button (hardware button) it send a notification to an android app. I have connected the data to firebase and used pusher to send notification. My device is integrate. But, I am unable to execute push notification curl command.
When I execute curl command (I even downloaded curl.exe and set the path):
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer **Secret Key**" \
-X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
-d '{"interests":["hello" ,"fcm":{"notification":{"title":"Hello", "body":"Hello, world!"}}}'
I got error in command prompt, like this:
C:\Windows\system32>curl -H "Content-Type: application/json" \
curl: (6) Could not resolve host: \
C:\Windows\system32> -H "Authorization: Bearer **Secret Key**" \
'-H' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32> -X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
'-X' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32> -d '{"interests":["hello"],"fcm":{"notification":{"title":"Hello", "body":"Hello, world!"}}}'
'-d' is not recognized as an internal or external command,
operable program or batch file.
The entire block should be a single command, but it seems your command line is executing a line at a time.
Try the below, which I should run as a single line command
curl -H "Content-Type: application/json" -H "Authorization: Bearer **Secret Key**" -X POST "https://**InstanceID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" -d '{"interests":["hello" ,"fcm":{"notification": "title":"Hello", "body":"Hello, world!"}}}'
I have curl request to push data to the server from Android.Below is the Curl request:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -H "Authorization: Token token=SNKh9UP4RX2Ltyxo9JnG , username=local1admin" -X PATCH -d '{"fcm": {"token":"sd7sdf6sdffd5"}}' http://myapp-back.herokuapp.com/fcms/1
How should I do post request using volley? I am confused because I have no idea where to put this:
'{"fcm": {"token":"sd7sdf6sdffd5"}}'
So please anyone help me to get it done. Any answers are appreciable. Thank you.
Peace out!
I ran into similar issue with my curl command below -
curl 'https://ws.test.com/handle_email?embed_load_code=undefined' -H 'Accept: /' -H 'Referer: https://cdn1.test.com/widgets/12345/12345/widget.html' -H 'Origin: https://cdn1.test.com' -H 'User-Agent: Test App' -H 'DNT: 1' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'campaign=12345&merchant=12345&original_data=%257B%2522site%2522%253A%2522site-11111-www.test.com%2522%257D&share_id=&email=test%40test.com' —compressed
Easy way to figure out how to organize the different pieces of cUrl query to Volley Request is by first running this cUrl query in Post Man and intercept request object in Charles Proxy - Ref : Simulate a specific CURL in PostMan
In my case -
-H values were added as Header items
--data values are added as body
Content-Type set as application/x-www-form-urlencoded
When I access my server with the following it works:
curl -X POST \
-H "X-Parse-Application-Id: xxx" \
-H "X-Parse-Master-Key: yyy" \
-H "Content-Type: text/plain" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
http://xx.xx.xx.xx/parse/classes/Inventory
But when I use the following, it doesn't:
curl -X POST \
-H "X-Parse-Application-Id: xxx" \
-H "Content-Type: text/plain" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
http://xx.xx.xx.xx/parse/classes/Inventory
I get this error instead:
{"error":"unauthorized"}
It worked perfectly fine earlier. I had changed a few settings and updated to the latest Parse Server version and then it stopped working, along with all the other apps related to it.
The web version works, suggesting that the REST API key was fine. I can access everything perfectly through the Dashboard too. The only problem is when I access it with Android, which can only give an Application Id for identification.
Might I have changed a setting wrong that blocked this? I don't think I changed anything, though there is the small possibility I didn't close a bracket or commented something out on the server.js file.
It's brought up here: https://github.com/parse-community/parse-server
The client keys used with Parse are no longer necessary with Parse Server. If you wish to still require them, perhaps to be able to refuse access to older clients, you can set the keys at initialization time. Setting any of these keys will require all requests to provide one of the configured keys.
clientKey
javascriptKey
restAPIKey
dotNetKey
What happened was that I had restAPIKey inside my config file, so it required any one of the other four keys as well. The new update forced my app to use clientKey or remove restAPIKey from the config.
I am trying to migrate my Parse app to MongoDB. I have got MangoDB up up and running and connected to pars.com server as described in parse.com/docs/server/guide#migrating.
Now I am trying to connect to my Parse server from Android Parse SDK version is 1.13.0.
Initialization is:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("apid")
.clientKey("key")
.server("http ://server:1337")
.enableLocalDataStore()
.build());
GET method works fine from command line:
curl -X GET -H "X-Parse-Application-Id: " -H "X-Parse-Master-Key: " -G http : //serverip:1337/classes/New/EXOIesqEa3 {"objectId":"EXOIesqEa3","Name":"Third","createdAt":"2016-01-31T14:24:18.950Z","
However, it dose not work in Android SDK, as it uses POST instead of GET with body, something like:
curl -X POST -H "key" -H "Content-Type: application/json" -d '{"where":"{\"objectId\":\"iXMRHnQN1a\"}","_method":"GET"}' http://server:1337/classes/GameScore1
Parse server response is InvalidKeyName exception: {"code":105,"error":"invalid key name: 0"}.
Can someone help here to figure out why it returns this InvalidKeyName exception?
Please note that:
curl -X POST -H "X-Parse-Application-key" -H "Content-Type: application/json" -d '{"_method":"GET"}' http://server:1337/classes/GameScore1
works fine.