Chrome Web notification 'MismatchSenderId' error - google-chrome

I have deployed the sample code for Chrome push notifications and updated the gcm_sender_id to a newly configured project, the client is able to subscribe/unsubscribe without issue but when posting a request to send a notification the response MismatchSenderId is continually returned.
I have tried creating multiple new projects console.firebase.google.com, but nothing seems to work.
Request:
POST /gcm/send HTTP/1.1
Host: android.googleapis.com
Authorization: key=<Server Key/>
Content-Type: application/json
{
"registration_ids":[
"<Registration-ID/>"
]
}
Response:
{
"multicast_id": 6881038306061588882,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "MismatchSenderId"
}
]
}
I am using the 'Server Key' as the request auth token (which works as 401 is returned when an invalid key is used) and am using the 'Sender ID' in the manifest:
manifest.json
{
"name": "Notification Demo",
"gcm_sender_id": "<Sender ID/>"
}

This was my own fault; the sample registration ID's were in a different format to the generated ones I was seeing and did not contain semicolons which I was using to strip the registration ID from the subscription endpoint string. Splitting the endpoint by a forward slash and taking the last instance returned the correct Registration ID which works fine.

Related

How to determine why an Azure Function App is not triggered by a webhook

I have:
An JavaScript Azure Function in an HTTP webhook configuration; the Function provides a URL; the Function performs an action
A webhook configured in the software I hope to receive notifications from
An Azure Logic App with an HTTP/webhook step that provides a URL for the webhook notification to go to
My goal is that the Azure Function's URL receives notifications from the software's webhook and performs an action. The Azure Logic App is for testing only.
What works
When the the Azure Logic App's URL is used in the software's webhook configuration, the desired action is performed. All works as expected.
The Azure Logic App's logging shows the JSON output from the incoming webhook. I expect (but believe this may be where I am going wrong) that this is the JSON the webhook is sending to the Azure Logic App's URL. When this JSON is used in the Azure Function UI's "Test" tab > "Request body" field, the desired action is performed. All works as expected.
When the Azure Function's URL and the JSON is in a Postman request, the desired action is performed. All works as expected.
What doesn't work
When the Azure Function's URL is used in the software's webhook configuration, no action is performed. This is of course my goal. From everything I have read, I understand that this URL as a webhook endpoint should work.
Azure Function's URL
This is from Get function URL > default (Function key).
https://<app_name>.azurewebsites.net/api/content?code=<api_key>
Other Azure Function config settings
Allowed HTTP methods: GET, POST
Authorization level: Function
The JSON I believe to be coming over the webhook
{
"headers": {
"Expect": "100-continue",
"Host": "redacted",
"X-Telligent-Webhook-Sender": "redacted",
"Content-Length": "16908",
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}
}
I also tried with the following test code for the same results. It aligns more closely with the sample payload data provided by the software company:
What I tried
{
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}
Sample payload data
{
"events": [
{
"TypeId": "407ad3bc-8269-493e-ac56-9127656527df",
"DateOccurred": "2015-12-04T16:31:55.5383926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
},
{
"TypeId": "3b75c5b9-4705-4a97-93f5-a4941dc69bc9",
"DateOccurred": "2015-12-04T16:48:03.7343926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
}
]
}
I do not know how to determine why the Azure Function is not triggered by the webhook. The software's API documentation does not seem to provide a way to look at the JSON being sent over the webhook, although in my inexperience I may be wrong.
Is there a mechanism within Azure, or Postman, or another tool that lets me see what JSON is being sent over the webhook? Or perhaps is there another approach to determining the cause of the issue?
Thank you for any help.
This is how I got the JSON file from Azure alerts.
Install Ruby on the server
Install Sinatra with following command gem install sinatra
Create file webhook.rb and paste code bellow
require 'sinatra'
set :port, 80
set :bind, '0.0.0.0'
post '/event' do
status 204 #successful request with no body content
request.body.rewind
request_payload = JSON.parse(request.body.read)
#append the payload to a file
File.open("events.txt", "a") do |f|
f.puts(request_payload)
end
end
Run the web service with command ruby webhook.rb
JSON fill be written to file events.txt

"Invalid JSON","error":"invalid_value"

Hi I am trying to use workato to create a task for Podio. I have successfully connected to Podio using their HTTP OAUTH2 connection, but when I try to actually create the task using JSON, I receive this from Podio:
This is from HTTP:
400 Bad Request:
{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http://api.podio.com/task/","query_string":"","method":"POST"},"error_description":"Invalid
JSON","error":"invalid_value"}
The Code is as follows:
Request URL : https://api.podio.com/task/item/"the item id" <--This is where I would place the itemID of the item in Podio
Request header:
Authorization: OAuth2 [[User.SiteAccessToken]]
Content-type: application/json
Request Body:
{
"text": "Regarding Absence Request for Vacation",
"responsible":"{"type":profile, "id": "this is my profileID" }",
"description": "Your request for Vacation has been denied, please contact your manager."
}
but when I run this, I get this error message:
400 Bad Request:
{"error_parameters":{},"error_detail":null,"error_propagate":false,"request":{"url":"http://api.podio.com/task/item/436023600","query_string":"","method":"POST"},"error_description":"Invalid
JSON","error":"invalid_value"}
Now within the the request body or header does it need to have which app I am referring to not just the item ID. Not sure what it's looking for, if you could please assist with some guidance, that would be greatly appreciated.
I discovered that the issue was indeed the syntax within the JSON sent in the request body.
The quotes around the curly braces for responsible needed to be removed and I needed quotes with profile, and it should have gone like this:
{
"text": "Regarding Absence Request for Vacation",
"responsible": {"type":"profile", "id": 123 },
"description": "Your request for Vacation has been denied, please contact your manager."
}

FineUploader Failing to parse incoming JSON

I'm using play/scala for a webapp and a scala API, currently running simply on two different ports on localhost:9000 and localhost:8080 respectively. I have the basic page from the fine-uploader.com website docs, and a simple test page build in Play. (FWIW, i don't think much of the above is relevant)
When i post a file, chunked or not, Fine uploader receives a 200 from the API and valid JSON, but JSON.parse returns a failure. The logging from fine-uploader is below. If i take this output and run it through (in the console)
JSON.parse(JSON.stringify(json))
a valid object is returned. I can't just JSON.parse(json) directly in the browser tools b/c its already an object. I have checked the types by console.log'ing typeOf json in the qq.parseJson method and it returns string, so no conversion should be required, though i have tried it with the same results.
fine-uploader console logs:
[Fine Uploader 5.5.1] Sending simple upload request for 0 fine-uploader.js:251
[Fine Uploader 5.5.1] xhr - server response received for 0 fine-uploader.js:251
[Fine Uploader 5.5.1] responseText = {"code":"UPLOAD_COMPLETE","response":{"MediaModel":{"id":1103,"publicUri":"http://localhost:8080/media/Archive.zip","fileLocation":"/src/services/api/src/main/webapp/media/Archive.zip","mediaDate":{"year":2016,"month":2,"day":28},"mediaOrder":1,"viewName":"","caption":"","altText":"","isPublic":1,"fileSize":1107080,"created":"2016-02-28T14:58:43Z"},"UserMediaModel":{"id":1,"userId":24,"mediaId":3,"created":"2016-02-17T12:48:18Z"}},"errors":[]} fine-uploader.js:251
[Fine Uploader 5.5.1] Received response status 200 with body: {"code":"UPLOAD_COMPLETE","response":{"MediaModel":{"id":1103,"publicUri":"http://localhost:8080/media/Archive.zip","fileLocation":"/src/services/api/src/main/webapp/media/Archive.zip","mediaDate":{"year":2016,"month":2,"day":28},"mediaOrder":1,"viewName":"","caption":"","altText":"","isPublic":1,"fileSize":1107080,"created":"2016-02-28T14:58:43Z"},"UserMediaModel":{"id":1,"userId":24,"mediaId":3,"created":"2016-02-17T12:48:18Z"}},"errors":[]} fine-uploader.js:251
[Fine Uploader 5.5.1] Simple upload request failed for 0
The server is responding with a 200 per the API logs and i can see the exact response object in the Response tab of Chrome Dev tools.
I added a custom error handler, but not more more information was provided, just that the error is the text output
Error on file number 0 - Archive.zip. Reason: {"code":"UPLOAD_COMPLETE",....same as above
Lastly, all rows are propery inserted into the database as you see from the id's created above. And all logging points to an equally successful action.
Thanks for any pointers. I've also put this output in http://jsonlint.com/ and it parses fine.
Thanks! (sorry for the lack of JSON formatting, i can change it, but this seemed long enough already)
EDIT
It seems that i have satisfied the requirements stated in the other question with "success":true and Content-Type=text/plain. The following, per request is the JSON output and the headers
Headers:
Key: Access-Control-Allow-Origin Value: http://localhost:9000
Key: Date Value: Mon, 29 Feb 2016 00:55:19 GMT
Key: Access-Control-Allow-Credentials Value: true
Key: Content-Type Value: text/plain; charset=UTF-8
{
"code": "UPLOAD_COMPLETE",
"response": {
"MediaModel": {
"id": 1169,
"publicUri": "http://localhost:8080/media/Archive.zip",
"fileLocation": "/src/services/api/src/main/webapp/media/Archive.zip",
"mediaDate": {
"year": 2016,
"month": 2,
"day": 28
},
"mediaOrder": 1,
"viewName": "",
"caption": "",
"altText": "",
"isPublic": 1,
"fileSize": 1107080,
"created": "2016-02-29T00:55:19Z"
},
"UserMediaModel": {
"id": 1,
"userId": 24,
"mediaId": 3,
"created": "2016-02-17T12:48:18Z"
}
},
"errors": [],
"success": true
}
I'm sure this will end up being something silly, so i appreciate the input.
Based on the error reported by Fine Uploader, your response is not properly formatted. If you look closely at the response in your browser's network tab (such as with Chrome dev tools), you'll likely see a JSON string that, once parsed using JSON.parse results in another JSON string instead of a JavaScript object containing the expected properties. I can't confirm this as you haven't posted the exact response from your server, but I'm certain that this is the case. This is most likely caused by an encoding issue server-side. For example, your server should return this: {"foo": "bar", "success": true} instead of this: "{\"foo\": \"bar\", \"success\": true}". I suspect your server is returning the latter.

How to work xtify simple push api in chrome postman application

I have tried to rin the xtify simple push api in post manbut it shows error. I have used the following json code in raw body:
{
"apiKey":"12345678-7d94-415a-9eed-00987654321",
"appKey":"12345678-4ab7-4633-8a7c-00987654321",
"sendAll": true,
"content": {
"message": "Arma virumque cano, troiaeque primus ab oris",
"sound": "default.caf",
"badge": "+1",
"action": {
"type": "CUSTOM",
"label":"Open",
"data": "{'action_id': 'ABC', inum: '123456'}"
}
}
}
I have valid api key and app key. I have changed here the api key and app key for security reason. Using header Content-Type=application/json but it shows the error message:
Invalid Application Key
Actually I have used this url https://api.xtify.com/2.0/push for sending push. But it should be like this https://euapi.xtify.com/2.0/push. It works now

authorization_invalid_request error when preparing DocuSign envelope for tab modification

I am trying trying to create a draft envelope from a template and then modify some of the tabs in the template. I'm getting an AUTHORIZATION_INVALID_REQUEST response.
My initial request is to the following URL https://demo.docusign.net/restapi/v2/accounts/<account id>/envelopes
and the payload is as follows:
{
"status": "created",
"emailSubject": "2015-01-27T16:25:43.133-05:00 Docusign Template Request",
"emailBlurb": "email blurb",
"templateId": "<template id>",
"brandId": "<brand id>",
"templateRoles": [
{
"name": "<name>",
"email": "<email>",
"roleName": "<role>",
"clientUserId": "",
"emailNotification": {
"supportedLanguage": "en",
"emailSubject": "<subject>",
"emailBody": "special email body"
}
}
],
"allowReassign": "true",
"enableWetSign": "false",
"messageLock": "false"
}
That produces the following response:
{
"envelopeId": "<envelope id>",
"uri": "/envelopes/<envelope id>",
"statusDateTime": "2015-01-28T22:09:43.9770000Z",
"status": "created"
}
Then I send a recipient view request to the following URL:
https://demo.docusign.net/restapi/v2/envelopes/<envelope id>/views/recipient using the envelope id received in the above response.
This results in the following response:
{
"errorCode": "AUTHORIZATION_INVALID_REQUEST",
"message": "The authorization request is malformed."
}
Note that if I had set the first request above to a status of "sent" (and thus did not create a draft envelope), the second request would have been successful.
However according to DocuSign documentation (p. 163 of the API guide), the modify tabs API call "modifies one or more tabs for a recipient to a draft envelope". Accordingly to perform a tab modification I need a draft envelope, not a sent one. But when I create a draft envelope, the views/recipient call fails as above.
I can add tabs successfully to a "sent" envelope. But I would rather modify tabs and am having trouble doing that.
You're not hitting a valid DocuSign Endpoint. Where did you get the /v2/envelopes/<envelope id>/views/recipient URL from? That's not a proper URL hence the error message you are getting.
After you create the envelope if you want to modify a given recipient's tabs then you need to make the following API call:
Modify Tabs for Recipient
Note that this is a PUT call not a POST, and URI is:
/accounts/{accountId}/envelopes/{envelopeId}/recipients/{recipientId}/tabs
For example, if you wanted to modify tabs for recipient who is recipientId = 3 you would make a call similar to (notice the 3 in the URL):
PUT https://demo.docusign.net/restapi/v2/accounts/12345/envelopes/{envelopeId}/
recipients/3/tabs
X-DocuSign-Authentication: <DocuSignCredentials><Username>{name}</Username><Password>{password}</Password><IntegratorKey>{integrator_key}</IntegratorKey></DocuSignCredentials>
Accept: application/json
Content-Type: application/json
{
"approveTabs":[{
<Tab information removed>
}],
"titleTabs":[{
<Tab information removed>
}],
"signHereTabs":[{
<Tab information removed>
}]
}
I'm not sure if this qualifies as an "answer" to my question, but it does appear that the problem has somehow been resolved. I let it rest for a couple days while I attended to other matters, then yesterday afternoon suddenly it started working, with no changes on my part. The specific part that wasn't working was attempting a PUT on an envelope in order to modify the tags. That is not supposed to work unless the envelope is a draft; my envelopes have all been drafts. Wasn't working a couple days ago, and now it is. #Pete and #Dorian: you might want to try it again if you haven't already; if you're not doing anything else wrong it might work now.