Even by using sample project provided in Corona SDk , I get a notification with error 400. I guess my json data is correct. Following is the code for Json message.
local jsonMessage =
[[
"registration_ids": ["]] .. tostring(googleRegistrationId) .. [["],
"data":
{
"alert": "Hello World!",
"sound": "default"
}
}
]]
This is the message on my device.
Based on the 400 error code, the problem must be your JSON :
400
Only applies for JSON requests. Indicates that the request could not
be parsed as JSON, or it contained invalid fields (for instance,
passing a string where a number was expected). The exact failure
reason is described in the response and the problem should be
addressed before the request can be retried.
With all the square brackets and html tag, it's really hard to understand from your question how your JSON actually looks like.
Anyway, here's how it should look like :
{
"registration_ids": ["some reg id"],
"data":
{
"alert": "Hello World!",
"sound": "default"
}
}
I solved this error by changing the format of my json and checking the format on this link http://jsonlint.com/# . This was a great help and also I replace alert icon by custom icon by using this:
http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
Related
I am currently working on new android project with feathersjs back-end. Before error response normal format like,
{
"code": 123,
"message": "An error occurred!"
}
But now structure change dynamically according to the api request body. For Example I have three input field in my UI like Name, age, email after hitting api if wrong data error response will be like,
{
"code":123,
"error":{
"name":"Name is wrong",
"age":"Age is greater than 18 is mandatory",
"email:"Invalid email id"
}
}
So I need to link Error response to correct Edittext Field and set Error Message. How I link this ?. But Request Body field name and error response field name are same.
Request Body structure :
{
"data":{
"name":"xxx",
"age":"24",
"email:"xx#gmail.com"
}
}
Detail Explanation with Example Code will be more helpful.
I'm currently building a logic app in Azure to send text messages with Twilio. Everything is working smoothly except that I can't send complex URL in the body.
For exemple if I send this : https://example.com?id=26 I will recieve the the correct string, but the parameter is not concatenated correctly with the domain in the clickable link.
So when I click the link in the text message it only opens the https://example.com . The message I'm sending is built like this :
"Send_Text_Message_(SMS)": {
"inputs": {
"body": {
"body": "#{triggerBody()?['message']}#{triggerBody()?['url']}#{body('Insert_row')?['Id']}",
"from": "xxx-xxx-xxxx",
"to": "#triggerBody()?['phone']"
},
message: Hello please click this link
url :https://example.com?id=
id: 26
so the final body would be like : [message][url][id]
I've tried sending a simple string like https://example.com?id=8 to see if it was the "complex" body concatenation that was failing, but it's still not working.
Can anyone help :) ?
For anyone that would be stuck with this here's how I tricked android :
I added a / after the .com so now the url I'm sending is :
https://example.com/?id=36
I'm using the wikimapia api for developing an Android application. I've used my first key for about two months but not, for any request I make I get:
{
"debug": {
"code": 1004,
"message": "Key limit has been reached"
}
}
I've created a new key, but now, for any request I make I get the same response: []
Does anybody know what the problem is?
It looks like something wrong on Wikimapi side. It returns me [] too.
There are few post about this issue on wikimapia forum
http://wikimapia.org/forum/viewtopic.php?f=4&t=14933&p=288045&hilit=empty#p288045
I've studied this page:
https://developers.google.com/gmail/api/v1/reference/users/messages/import
I have some messages I will be keeping track of in my Android program. I will be keeping a record of the messages I will be deleting and I would like to import those messages slated for deletion into a new folder (In Gmail API folders are called Labels).
I tried the test form:
POST https://www.googleapis.com/gmail/v1/users/omitted%40gmail.com/messages/import?deleted=false&internalDateSource=dateHeader&neverMarkSpam=true&processForCalendar=false&key={YOUR_API_KEY}
{
"payload": {
"body": {
"data": "hellio"
}
}
}
Response:
400 OK
- SHOW HEADERS -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "'raw' RFC822 payload message string or uploading message via /upload/* URL required"
}
],
"code": 400,
"message": "'raw' RFC822 payload message string or uploading message via /upload/* URL required"
}
}
There is a problem sending the request but I am not sure at all what it means. What I need is some Java that sends a request that will import a message where I can specify the body, received date and subject line. Is it possible?
Thank you.
P.S. I just wanted to delete the attachments not the whole message but after reading the Gmail API documents it looks like this is not possible and is only possible through IMAP. The reason I am asking this question is so that I don't have to move my whole program to IMAP.
You are pretty close with your code. What you need to do is write a mail compliant with the RFC 2822 standard, and Base64-encode said mail and make it URL-safe (replace all + with - and all / with _) before inserting it.
You are better at Java than me, but if I would make a correct message in the browser's Developer Console, it could look something like this:
var encodedMail = btoa(
"Date: Thu, 1 Jan 1970 12:00:00 -0000\n" +
"From: emtholin#gmail.com\n" +
"To: emtholin#gmail.com\n" +
"Subject: Example Subject\n\n" +
"This is the body of the mail"
).replace(/\+/g, '-').replace(/\//g, '_');
Then I just insert this mail with the same request you issued:
POST https://www.googleapis.com/gmail/v1/users/me/messages?internalDateSource=dateHeader&key={YOUR_API_KEY}
{
"raw": "RGF0ZTogVGh1LCAxIEphbiAxOTcwIDEyOjAwOjAwIC0wMDAwCkZyb206IGVtdGhvbGluQGdtYWlsLmNvbQpUbzogZW10aG9saW5AZ21haWwuY29tClN1YmplY3Q6IEV4YW1wbGUgU3ViamVjdAoKVGhpcyBpcyB0aGUgYm9keSBvZiB0aGUgbWFpbA=="
}
As you can see, this worked great!
{
"German":[
"Hello",
"guten Morgen",
"gute Nacht"
],
"English":[
"Hello",
"good morning",
"good Night"
],
"French":[
"bonjour",
"bonne nuit",
"bonjour"
]
}
In Android ,I have to parse this above output. I am unable to do. can any one tell me ,does it wrong jSON output or it is correct ?
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
Its problem with your URL - saqib_abbasi.0fees.net/Response.php
Try after removing the underscore from your host name.
See the following links
https://stackoverflow.com/a/11206362/1329126
http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
It's a valid json. So you didn't do something right.
Make a JSONObject from the whole string, then you can get the arrays with getJSONArray("German") for example.