Trying to use IO Keen for Android, i'm using Android Sample available here (https://github.com/keenlabs/KeenClient-Android-Sample) the data is being sent, but they are always duplicate and the second always contains junk.
The HashMap event is clean before adding in the queue.
Am I the only one?
Watch these :
{
"keen": {
"timestamp": "2015-01-22T18:08:49.863Z",
"created_at": "2015-01-22T18:09:07.589Z",
"id": "54c13cc3672e6c486c7a28bb"
},
"click-number": 0
}
{
"keen": {
"timestamp": "2015-01-22T18:09:07.590Z",
"created_at": "2015-01-22T18:09:07.590Z",
"id": "54c13cc3672e6c486c7a28bc"
},
"-537732783": 3
}
"-537732783": 3 What is that?
Logcat :
FINER: Sent request '{"android-sample-button-clicks":[{"click-number":0,"keen":{"timestamp":"2015-01-22T13:14:19.075-0500"}}]}' to URL 'https://api.keen.io [...]
FINER: Received response: '{"android-sample-button-clicks": [{"success": true}]}' (200)
FINER: Sent request '{"android-sample-button-clicks":[{"-1236199318":1}]}' to URL 'https://api.keen.io [...]
FINER: Received response: '{"android-sample-button-clicks": [{"success": true}]}' (200)
This was caused by a bug in the 2.1.0 release of the SDK. It has been fixed in the 2.1.1 release.
(In more detail: the bug was in the retry limiting logic that was added as part of 2.1. See this PR for the fix: https://github.com/keenlabs/KeenClient-Java/pull/37)
Sorry for the mistake!
Related
I am trying to use the Google Health API with a REST API. I am aware there is an API available for Android but I am trying to port that behavior to a back end.
I am playing around in the Oauth playground; I am trying to get a aggregated query. I've tried many things but none of them return anything (only get errors) There is no example featured on the google website itself. Anyone has experience with this API?
I have found a few examples here on stackoverflow but none of them conclude with a solution or a full query that can fit as an example.
Here and Here
If I just could get a working aggregate example I would work from there.
Here is my request to https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate:
{
"startTimeMillis": 1451647796000,
"endTimeMillis": 1458127796000,
"aggregateBy": [
{
"dataTypeName": "com.google.height"
}
],"bucketByTime": {
"period": {
"type": "day",
"value": 1,
"timeZoneId": "org.joda.timezone.DateTimeZone"
}
}
}
Response:
{
"error": {
"code": 400,
"message": "Bad Request",
"errors": [
{
"domain": "global",
"message": "Bad Request",
"reason": "invalidArgument"
}
]
}
}
You forgotten "durationMillis" field on "bucketByTime" and "dataSourceId" on "aggregateBy".
Timezone syntax is like "America/Los_Angeles" not "org.joda.timezone.DateTimeZone". You can see this strings on http://joda-time.sourceforge.net/timezones.html
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!
I'm having a major issue and hope someone can help.
We have web and Android applications which use Parse as their backend. The issue we are having occurrs on both. I'll explain the Android issue.
We use the REST API to save data up to Parse.com. The reason we do not use the SDK is that we want to take advantage of the batch operation which is only available in the RESTAPI.
{
"requests": [
{
"body": {
"isFriable": false,
"haDetail": "",
"sizeOther": "",
"colourOther": "",
"texture": "",
"fieldInspection": {
"__type": "Pointer",
"className": "FieldInspection",
"objectId": "YS5bXHBwDu"
},
"surfaceSubType": {
"__type": "Pointer",
"className": "SurfaceSubType",
"objectId": "d4IL5k1pv5"
},
"size": {
"__type": "Pointer",
"className": "HomogenousMaterialSize",
"objectId": "ezr3uHDUvt"
},
"colour": {
"__type": "Pointer",
"className": "HomogenousMaterialColour",
"objectId": "NqYXJcOkPE"
}
},
"method": "POST",
"path": "/1/classes/HomogenousArea"
}
]
}
The above is my request. This gets pushed to https://api.parse.com/1/batch using a basic default HttpClient.
When we execute the HTTP request it sometimes just hangs, it does not return any result. Roughly one in every 5 or 6 requests does this. The exact same data on a subsequent request that succeeds will go through fine. The problem is that at that point we have duplicate records persisted to Parse as our sync logic never completed since we did not get a response.
Is there anything in Parse we can use to debug requests like this? Below is the current http client implementation we are using. NOTE: Also put in OkHttp from Square and hit the exact same issue.
// Instantiate the http client to make the batch request
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost post = setupHttpPost(url);
// Assign the data to the post
StringEntity entity = new StringEntity(insertData);
post.setEntity(entity);
// Setup the response handler
ResponseHandler response = new BasicResponseHandler();
// Make the call to Post the new data
Object rersponse = httpClient.execute(post, response);
if (rersponse != null) {
return rersponse.toString();
}
return null;
wierd behavior of the ./batch....
Make sure that you are NOT missing parse error responses. IMO - sometimes there may be JSON parse errors or something that can be missed if you are not paying close attention to the handler on the Entity in the http Response....
I have not used Parse batch api. I have used multithread http client and not seen prevalent timeout type issues that you mention?
Since you use REST, you should be able to wrap some test calls in CURL client that you can instrument with CURL CLI switches to provide more -debug ...
Since you use REST, you could switch from batch interface to a multi-threaded client, ( see the "threads" example, see "config" example at org.apache ...
Wild guess but if you break down your batches maybe a background of higher number of Http EXEC's each with smaller payload may work out better????
The config example at the link shows how you can config the pool sizes by domain and how you can instrument the Timeouts ( conn timeout, req timeout etc ).
I spent the last 5 hours trying to get large picture from Facebook page using this request:
https://graph.facebook.com/v2.1/Y.Anti.coup.D?fields=name,picture?type=large&access_token=CAAHH9uJXXOcBA
But I always get this error:
{ "error": {
"message": "Syntax error \"Expected end of string instead of \"?\".\" at character 12: name,picture?type=large",
"type": "OAuthException",
"code": 2500 } }
Sorry for my bad English, and I hope that you understand my problem.
You can do this a lot easier:
https://graph.facebook.com/page-id/picture?type=large
(no Access Token needed btw)
In your case, the problem is that you are using the question mark two times. This is how your code should work:
https://graph.facebook.com/v2.1/Y.Anti.coup.D?fields=name,picture&type=large&access_token=CAAHH9uJXXOcBA
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