I want to use one signal to send VoIP push notifications to the iPhone. so I created a VoIP push notification and uploaded the p12 certificate to one signal dashboard in postman or curl. When I send a notification, it returns 200 (status success) but no notification is sent to my device. do you have any idea why?
request :
curl --include \
--request POST \
--header "Content-Type: application/json" \
--data-binary "{\"app_id\" : \"xxxxxxxx-xxxx-4a41-ac20-363497c923e5\",
\"identifier\":\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",
\"language\":\"en\", \"device_type\":0,
\"tags\":{\"FirstName\":\"amir\",\"LastName\":\"tutunchi\",\"Speciality\":\"Yoga\",\"MeetingID\":\"456354646\",\"AppointmentDate\":\"2019-05-29T22:45:47+04:30\",\"AppointmentTitle\":\"check\"}}"\
https://onesignal.com/api/v1/players
response :
{
"success": true,
"id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" }
Related
I'm trying to retrieve yesterday's transfer for one of our customers. Please check the following curl request
curl --request GET \
--url https://api.stripe.com/v1/transfers \
--header 'Authorization: Basic ourPrivateKeyEncoded' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data destination=acct_anAccount \
--data created.gt=1629676800
I'm able to retrieve all the transfers of my customer, but the created filter is not accepted. Meaning the above request without the created.gt is ok.
With this filter Stripe respond me a 400 with this body
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: created.gt. Did you mean created?",
"param": "created.gt",
"type": "invalid_request_error"
}
}
I'm following this documentation, the created filter seems to exist. Does someone have an idea why Stripe doesn't accept my filter?
Replacing created.gt by created[gt] filter key made my request works.
The documentation seems to be outdated
I'm trying to control my Sonos One (Gen 1) speaker through cloud APIs but all the POST request return 500 Internal Server Error without error message.
I generated an access_token as described in the documentation and was able to obtain information about the 'households' inside my network, finally both the group id and the player id.
I tried to obtain information about the status of the group by performing a GET on the following endpoint and it worked:
https://api.ws.sonos.com/control/api/v1/groups/{{group_id}}/playback
Same with other GET requestes (e.g. groupVolume).
The problem arise when I try to make a POST (e.g. changing the volume or playing an audioClip), it returns 500 Internal Server Error without any body.
For all the requests I am using Postman including as Headers:
Content-Type: application/json
Authorization: Bearer [token]
Content-Length: ??? (automatically inserted by postman)
while for the body of the change volume request I select the raw option and then select JSON(application/json) option.
The body is:
{
"volume": 80
}
The endpoint is the following: https://api.ws.sonos.com/control/api/v1/groups/{{group_id}}/groupVolume
I also tried controlling the player with node (Package) and it works.
Also tried to use Wireshark to see what requests the node-sonos package is performing but it seems it's not using the Cloud APIs.
I expect the player to change volume, but the API doesn't do anything and doesn't return any error message.
EDIT:
The cURL request from POSTMAN is the following:
curl -X POST \
https://api.ws.sonos.com/control/api/v1/players/<playerID>/audioClip \
-H 'authorization: Bearer XXX' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: XXX' \
-d '{
"appId": "edu.myInstitute.myName",
"clipType": "CUSTOM",
"name": "Test",
"streamUrl": "http://...mp3_file_url"
}'
I am getting this rather unhelpful error and it seems to occur for a large variety of things based on the SO posts. So here I am.
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note... I granted "Group.ReadWrite.All" under "Delegate" as the create channel API doc says I should. I left everything else in the App as default.
I then do a token request like so:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
"https://login.microsoftonline.com/$TENANT/oauth2/v2.0/token" \
-d "client_id=$APP_ID" -d "scope=https%3A%2F%2Fgraph.microsoft.com%2F.default" \
-d "client_secret=$PASSWORD" -d "grant_type=client_credentials"
which gives me this mess:
{"token_type":"Bearer","expires_in":3600,"ext_expires_in":0,"access_token":"BIG_LONG_TOKEN"}
I then take that token and stuff it into my Authorization header and make the call to create the channel:
curl "https://graph.microsoft.com/beta/groups/$TENANT/channels" \
-H "Content-type: application/json" \
-H "Authorization: Bearer $BIG_LONG_TOKEN" \
-d '{
"displayName": "mynewchannel",
"description": "Channel Description"
}'
But this results in tears and this:
{
"error": {
"code": "",
"message": "Authorization has been denied for this request.",
"innerError": {
"request-id": "c572f6df-7537-4a53-aefc-fcc8c71e2037",
"date": "2018-04-17T23:46:50"
}
}
}
I am not sure what I'm missing, but hopefully it's obvious to someone else...
EDIT: Interestingly, if I set TOKEN to garbage, I get a more helpful answer, but this indicates my TOKEN is at least mostly ok and it is more of a authorization rather than an authentication issue
TOKEN=garbage
curl -X GET "https://graph.microsoft.com/beta/groups/$TENANT/channels" -H "Content-type: application/json" -H "Authorization: Bearer $TOKEN"
Results in
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "CompactToken parsing failed with error code: 80049217",
"innerError": {
"request-id": "166cb22b-c135-45e9-9f23-0e73bc68475d",
"date": "2018-04-18T00:20:47"
}
}
}
I went here https://apps.dev.microsoft.com, logged in and created a new App. I generated a secret and stored it for later on a post-it note...
According to Create Channel Rest API document, Application type permission is not supported. So you get the error information Authorization has been denied for this request.
Delegated permissions are used by apps that have a signed-in user present. For these apps either the user or an administrator consents to the permissions that the app requests and the app is delegated permission to act as the signed-in user when making calls to Microsoft Graph. Some delegated permissions can be consented to by non-administrative users, but some higher-privileged permissions require administrator consent.
As Wajeed - MSFT mentioned that you could use Graph explorer with your account login to have a try.
Note: APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.
I created a demo push notification by:
ionic start pushdemo
Add added the following code in app.js:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
var push = new Ionic.Push({
"debug": true
});
push.register(function(token) {
console.log("Device token:",token.token);
push.saveToken(token);
});
Add I created push certificate and provisioning profile for iOS and also create an app in google for GCM.
Then I set the dev_push to false in .io-config.json.
I tested for Android by running the app in emulator:
ionic run android -lc
Doing this, I can get the device token. Then I'm able to send push notification by curl command:
curl -X POST -H "Authorization: Bearer xxxxeXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI3NjI4MzUyNi1mZjMxLTRhMGItODAxOC0xZmM2ZTY0ZTA3N2YifQ.xCSZk4vQwKajGQ4TOoWyN5GIPnA14jhYfDRMDrtxxxx" -H "Content-Type: application/json" -d '{ "tokens": ["DEV-67e379b0-0752-424c-9a73-0503ce0ad385"], "profile": "pushdemo_dev", "notification": { "message": "Hello World!!!" }}' "https://api.ionic.io/push/notifications"
I have no problem to receive the push notification when the app is running in foreground. But I'm not able to get the push notification when the app is in background.
The other issue is that the device token is always changed when app restart. Is this normal?
Another problem is I'm not able to get push notification when I push message through Dashboard in ionic.io.
Any idea? Thanks.
EDITED:
When I tested on ios device, I'm able to get the device token something like: 5137fcda 88b7e401 2dc7ac21 e4d80f96 d8702ee6 cd6e08ac 874a0b20 9a9882b0. But I can't get push notification when I used the above mentioned curl command. The returned value is:
{"data": {"created": "2016-06-10T09:17:07.031440+00:00", "config":
{"profile": "pushdemo_dev", "notification": {"message": "Hello World
ios!!!"}, "tokens":
["5137fcda88b7e4012dc7ac21e4d80f96d8702ee6cd6e08ac874a0b209a9882b0"]},
"status": "open", "uuid": "151f86f9-8b09-4e9c-9402-779544dbcbd1",
"state": "enqueued", "app_id": "0dfdafd1"}, "meta": {"version":
"2.0.0-beta.0", "request_id": "99e6891c-4fa5-40a9-a1ec-2fd283905c5f",
"status": 201}}
EDIT 2:
Finally get it works in ios by using Postman to push. The format of device token returned is something like 5137fcda 88b7e401 2dc7ac21 e4d80f96 d8702ee6 cd6e08ac 874a0b20 9a9882b0. But when I post in Postman, I have to remove the space. However there is still a problem, I'm not able to receive push notification when I run the app in foreground. It only shows the push notificaiton when the app is running in background.
my program also doent working on real devices but it isworking on browser it means my io is working fine
and for you dont use dashboard instead use postman it is good
The example call in the PayPal Invoicing API documentation is returning an error?
Request
curl -s --insecure -H "X-PAYPAL-SECURITY-USERID: caller_1312486258_biz_api1.gmail.com" -H "X-PAYPAL-SECURITY-PASSWORD: 1312486294" -H "X-PAYPAL-SECURITY-SIGNATURE: AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e" -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" -H "X-PAYPAL-APPLICATION-ID:APP-80W284485P519543T" https://svcs.sandbox.paypal.com/Invoice/CreateAndSendInvoice -d {\"requestEnvelope\":{\"errorLanguage\":\"en_US\"},\"invoice\":{\"merchantEmail\":\"caller_1335455804_biz#x.com\",\"payerEmail\":\"sender_1335455648_per#x.com\",\"currencyCode\":\"USD\",\"paymentTerms\":\"DueOnReceipt\",\"itemList\":{\"item\":[{\"name\":\"BananaPlant\",\"quantity\":\"1\",\"unitPrice\":\"38.95\"},{\"name\":\"PeachTree\",\"quantity\":\"2\",\"unitPrice\":\"14.95\"}]}}}
Response
{"responseEnvelope":{"timestamp":"2013-08-22T23:58:47.340-07:00","ack":"Failure","correlationId":"4838886d6636b","build":"7236486"},"error":[{"errorId":"580001","domain":"PLATFORM","subdomain":"Application","severity":"Error","category":"Application","message":"Invalid request: {0}"}]}
Try wrapping the payload in the -d switch within "". Running the curl snippet with the -v switch as-is will show you that the payload gets truncated and hence the "Invalid request" error.
Also, you will see a "Invalid token" error when the merchantEmail in the request is not the same as the API caller. If you need to generate invoices on behalf of a third party (in which case the API caller and merchantEmail are naturally different), you must obtain third party permissions and attach a X-PAYPAL-AUTHORIZATION header to your request.