Start a new topic

Not able to save data using saveBlocking

 Here is the code snippet...


Client myJavaClient = new Client.Builder(appKey, appSecret).build();
myJavaClient.enableDebugLogging();
Boolean ping = ping = myJavaClient.ping();
System.out.println("Connected to client? " + ping);

User result = myJavaClient.user().loginBlocking("anujain", "anujain").execute();
System.out.println("isUserLoggedIn:: " + result.isUserLoggedIn());

eventE.setId("1");
eventE.setName("Office");
eventE.setLocation("Kharadi");
eventE.setTime("10AM");

AppData appData = myJavaClient.appData("EventCollection", EventEntity.class);
appData.saveBlocking(eventE).execute();


----------------------------------------------------------------------------------------


And here is the output:


Hello World
Connected to client? true
isUserLoggedIn:: true
Exception in main method:: com.kinvey.java.core.KinveyJsonResponseException: unknown
com.kinvey.java.core.KinveyJsonResponseException: unknown
at com.kinvey.java.core.KinveyJsonResponseException.from(KinveyJsonResponseException.java:91)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:441)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:357)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:466)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:133)
at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:43)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:159)
at HelloWorld.main(HelloWorld.java:88)


Ohhh, I apologize for the mistake. I didi a clean and build and here are the fresh logs. I still get same error.

Hello World
Aug 27, 2015 10:30:46 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
GET https://baas.kinvey.com/appdata/kid_-185TGTtNe
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79

Aug 27, 2015 10:30:46 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe'
Aug 27, 2015 10:30:47 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: b340c440e3ad4c908eee7893afd89877
X-Kinvey-API-Version: 3
Date: Thu, 27 Aug 2015 05:00:47 GMT
Content-Length: 99
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 27, 2015 10:30:47 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 99 bytes
Connected to client? true
Aug 27, 2015 10:30:47 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"version":"3.3.45","kinvey":"hello FirstApp","appName":"FirstApp","environmentName":"Development"}
Aug 27, 2015 10:30:47 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/user/kid_-185TGTtNe/login
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
X-Kinvey-API-Version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 43

Aug 27, 2015 10:30:47 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'X-Kinvey-API-Version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/user/kid_-185TGTtNe/login' << $$$
Aug 27, 2015 10:30:47 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 43 bytes
Aug 27, 2015 10:30:47 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"password":"anujain","username":"anujain"}
Aug 27, 2015 10:30:48 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: 59f7e7aecf2c4376ba54168311c51a90
X-Kinvey-API-Version: 3
Date: Thu, 27 Aug 2015 05:00:47 GMT
Content-Length: 524
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 27, 2015 10:30:48 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 524 bytes
Aug 27, 2015 10:30:48 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"_id":"55d1b5cdd3c20aac5700ec83","username":"anujain","email":"anubhavjain86@gmail.com","first_name":"Anubhav","last_name":"Jain","_kmd":{"lmt":"2015-08-17T10:22:05.321Z","ect":"2015-08-17T10:22:05.321Z","emailVerification":{"status":"confirmed","lastStateChangeAt":"2015-08-17T10:32:08.826Z","lastConfirmedAt":"2015-08-17T10:32:08.826Z","emailAddress":"anubhavjain86@gmail.com"},"authtoken":"62efe03e-0d52-4533-845a-347b1390a724.Nj091I6p0ZbNPzlvA6fs5Zp7l+t9iC9PjK72A1sFGrE="},"_acl":{"creator":"55d1b5cdd3c20aac5700ec83"}}
isUserLoggedIn:: true
Aug 27, 2015 10:30:48 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/
Accept-Encoding: gzip
Authorization: <Not Logged>
Content-Type: application/json; charset=UTF-8
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 52

Aug 27, 2015 10:30:48 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'Content-Type: application/json; charset=UTF-8' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/' << $$$
Aug 27, 2015 10:30:48 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 52 bytes
Aug 27, 2015 10:30:48 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"location":"Kharadi","name":"Office","time":"10AM"}
Aug 27, 2015 10:30:48 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Authorization needed"
X-Kinvey-Request-Id: e183ac97448446f4ae66d7ec94f7adfa
X-Kinvey-API-Version: 3
Date: Thu, 27 Aug 2015 05:00:48 GMT
Content-Length: 313
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

com.kinvey.java.core.KinveyJsonResponseException: unknown
Exception in main method:: com.kinvey.java.core.KinveyJsonResponseException: unknown
at com.kinvey.java.core.KinveyJsonResponseException.from(KinveyJsonResponseException.java:91)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:441)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:357)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:466)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:133)
at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:43)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:159)
at HelloWorld.main(HelloWorld.java:88)
 

 Thanks

AJ

Hello AJ,


The much more descriptive error message that our server is returning should give you some insight into why this isn't working:


{"error":"InsufficientCredentials","description":"The credentials used to authenticate this request are not authorized to run this operation. Please retry your request with appropriate credentials","debug":"Please authenticate as an app End User or as the app admin using the Master secret to run this operation"}


Please note, this not displaying correctly in the Java library is something that we plan to address, but for the time being this should help you understand the problem at hand (you need to be signed in as a user, or use master secret for this to succeed.   You cannot simply use the app secret to make this operation successful.


Thanks,


Hello Damien,

Thanks for taking a look into the code. I have modified the code as suggested but still no luck. Could you please take an another look?

1. Code snippet.
public static void main(String[] args) {
System.out.println("Hello World");

try {

Client myJavaClient = new Client.Builder(appKey, appSecret).build();
myJavaClient.enableDebugLogging();
Boolean ping = myJavaClient.ping();
System.out.println("Connected to client? " + ping);

User result = myJavaClient.user().loginBlocking("anujain", "anujain").execute();
System.out.println("isUserLoggedIn:: " + result.isUserLoggedIn());
EventEntity eventE = new EventEntity();
//eventE.setId("1");
eventE.setName("Office");
eventE.setLocation("Kharadi");
eventE.setTime("10AM");

AppData appData = myJavaClient.appData("EventCollection", EventEntity.class);
appData.saveBlocking(eventE).execute();

} catch (Exception e) {
System.out.println("Exception in main method:: " + e.toString());
e.printStackTrace();
}
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------

2 Output
Hello World
Aug 26, 2015 10:24:11 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
GET https://baas.kinvey.com/appdata/kid_-185TGTtNe
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79

Aug 26, 2015 10:24:11 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe'
Aug 26, 2015 10:24:12 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: 2f32a886378a46f3ace9190a1ed5ae65
X-Kinvey-API-Version: 3
Date: Wed, 26 Aug 2015 04:54:12 GMT
Content-Length: 99
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 99 bytes
Connected to client? true
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"version":"3.3.45","kinvey":"hello FirstApp","appName":"FirstApp","environmentName":"Development"}
Aug 26, 2015 10:24:13 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/user/kid_-185TGTtNe/login
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
X-Kinvey-API-Version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 43

Aug 26, 2015 10:24:13 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'X-Kinvey-API-Version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/user/kid_-185TGTtNe/login' << $$$
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 43 bytes
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"password":"anujain","username":"anujain"}
Aug 26, 2015 10:24:13 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: 8fffa8d3522f4674bcec1fb2c2a1404c
X-Kinvey-API-Version: 3
Date: Wed, 26 Aug 2015 04:54:13 GMT
Content-Length: 524
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 524 bytes
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
isUserLoggedIn:: true
CONFIG: {"_id":"55d1b5cdd3c20aac5700ec83","username":"anujain","email":"anubhavjain86@gmail.com","first_name":"Anubhav","last_name":"Jain","_kmd":{"lmt":"2015-08-17T10:22:05.321Z","ect":"2015-08-17T10:22:05.321Z","emailVerification":{"status":"confirmed","lastStateChangeAt":"2015-08-17T10:32:08.826Z","lastConfirmedAt":"2015-08-17T10:32:08.826Z","emailAddress":"anubhavjain86@gmail.com"},"authtoken":"aad11284-df55-4d68-8816-2f3238ee94e2.9yFsclzwrUZ3hY39/P+H1KGFoJ2u3zCf39QBJ483o28="},"_acl":{"creator":"55d1b5cdd3c20aac5700ec83"}}
Aug 26, 2015 10:24:13 AM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/
Accept-Encoding: gzip
Authorization: <Not Logged>
Content-Type: application/json; charset=UTF-8
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 61

Aug 26, 2015 10:24:13 AM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'Content-Type: application/json; charset=UTF-8' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/' << $$$
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 61 bytes
Aug 26, 2015 10:24:13 AM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"id":"1","location":"Kharadi","name":"Office","time":"10AM"}
Aug 26, 2015 10:24:14 AM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
Exception in main method:: com.kinvey.java.core.KinveyJsonResponseException: unknown
WWW-Authenticate: Basic realm="Authorization needed"
X-Kinvey-Request-Id: 46d4c324cce0427caaab829e49edc3e9
X-Kinvey-API-Version: 3
Date: Wed, 26 Aug 2015 04:54:13 GMT
Content-Length: 313
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

com.kinvey.java.core.KinveyJsonResponseException: unknown
at com.kinvey.java.core.KinveyJsonResponseException.from(KinveyJsonResponseException.java:91)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:441)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:357)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:466)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:133)
at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:43)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:159)
at HelloWorld.main(HelloWorld.java:88)


Thanks
Anubhav

 

Anubhav,


Based on the error output, it seems as though you didn't do a full clean and build.  If you take a look in the debug logs:


CONFIG: {"id":"1","location":"Kharadi","name":"Office","time":"10AM"}


Shows up despite id = 1 being commented out in your code above.  Can you please ensure that you are doing a full clean build and try this again?


Thanks,

Hello Anubhav,


Can you please enable library debugging as outlined here: http://devcenter.kinvey.com/java/guides/troubleshooting and let me know what you see in terms of server response?


Thanks,

I think previous comments didn't show up in the forum. Here are the logs..

Hello World
Aug 25, 2015 12:27:12 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
GET https://baas.kinvey.com/appdata/kid_-185TGTtNe
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79

Aug 25, 2015 12:27:12 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe'
Aug 25, 2015 12:27:14 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: bf40065b7f7241c3919240bc6aaca971
X-Kinvey-API-Version: 3
Date: Tue, 25 Aug 2015 06:57:14 GMT
Content-Length: 99
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 99 bytes
Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"version":"3.3.45","kinvey":"hello FirstApp","appName":"FirstApp","environmentName":"Development"}
Connected to client? true
Aug 25, 2015 12:27:14 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/user/kid_-185TGTtNe/login
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: android-kinvey-http/2.10.1
X-Kinvey-API-Version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 43

Aug 25, 2015 12:27:14 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'X-Kinvey-API-Version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/user/kid_-185TGTtNe/login' << $$$
Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 43 bytes
Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"password":"anujain","username":"anujain"}
Aug 25, 2015 12:27:14 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
X-Kinvey-Request-Id: 7dd0d03bbf4945ea99c07be180ee6902
X-Kinvey-API-Version: 3
Date: Tue, 25 Aug 2015 06:57:15 GMT
Content-Length: 524
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 524 bytes
Aug 25, 2015 12:27:14 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"_id":"55d1b5cdd3c20aac5700ec83","username":"anujain","email":"anubhavjain86@gmail.com","first_name":"Anubhav","last_name":"Jain","_kmd":{"lmt":"2015-08-17T10:22:05.321Z","ect":"2015-08-17T10:22:05.321Z","emailVerification":{"status":"confirmed","lastStateChangeAt":"2015-08-17T10:32:08.826Z","lastConfirmedAt":"2015-08-17T10:32:08.826Z","emailAddress":"anubhavjain86@gmail.com"},"authtoken":"493f4900-2c1f-4b73-9910-5559b16e873a.oRkcahgYQ/zhj10n3XvawgAClP9Eq7zBYE2TjB0LMv0="},"_acl":{"creator":"55d1b5cdd3c20aac5700ec83"}}
isUserLoggedIn:: true
Aug 25, 2015 12:27:15 PM com.google.api.client.http.HttpRequest execute
CONFIG: -------------- REQUEST --------------
POST https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/
Accept-Encoding: gzip
Authorization: <Not Logged>
Content-Type: application/json; charset=UTF-8
User-Agent: android-kinvey-http/2.10.1
x-kinvey-api-version: 3
x-kinvey-device-information: JAVA/1.7.0_79
Content-Type: application/json; charset=UTF-8
Content-Length: 61

Aug 25, 2015 12:27:15 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'Content-Type: application/json; charset=UTF-8' -H 'User-Agent: android-kinvey-http/2.10.1' -H 'x-kinvey-api-version: 3' -H 'x-kinvey-device-information: JAVA/1.7.0_79' -H 'Content-Type: application/json; charset=UTF-8' -d '@-' -- 'https://baas.kinvey.com/appdata/kid_-185TGTtNe/EventCollection/' << $$$
Aug 25, 2015 12:27:15 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 61 bytes
Aug 25, 2015 12:27:15 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"id":"1","location":"Kharadi","name":"Office","time":"10AM"}
Aug 25, 2015 12:27:15 PM com.google.api.client.http.HttpResponse <init>
Exception in main method:: com.kinvey.java.core.KinveyJsonResponseException: unknown
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Authorization needed"
X-Kinvey-Request-Id: 4fc7bfb628ea4098a132a5681f18f97d
X-Kinvey-API-Version: 3
Date: Tue, 25 Aug 2015 06:57:15 GMT
Content-Length: 313
Content-Type: application/json; charset=utf-8
X-Powered-By: Express
Server: ngx_openresty

com.kinvey.java.core.KinveyJsonResponseException: unknown
at com.kinvey.java.core.KinveyJsonResponseException.from(KinveyJsonResponseException.java:91)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:70)
at com.kinvey.java.core.AbstractKinveyJsonClientRequest.newExceptionOnError(AbstractKinveyJsonClientRequest.java:28)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:441)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:357)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:466)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.offlineFromService(AbstractKinveyOfflineClientRequest.java:133)
at com.kinvey.java.offline.OfflinePolicy$1.execute(OfflinePolicy.java:43)
at com.kinvey.java.offline.AbstractKinveyOfflineClientRequest.execute(AbstractKinveyOfflineClientRequest.java:159)
at HelloWorld.main(HelloWorld.java:88)
BUILD SUCCESSFUL (total time: 3 seconds)

 

Alright, thank you for posting that.


To get into what we think is happening:


1.The line of code:

Boolean ping = ping = myJavaClient.ping();


Is not valid Java.  This should probably be: Boolean ping = myJavaClient.ping();


2. This issue is most likely a problem with the user you're trying to use not being on the ACL for the object you are trying to save to.  If you remove the line of code:

eventE.setId("1");


This should allow the ID to be set automatically, which would then assign this to a randomized ID, which would then have this user as the ACL creator, and thus able to save over it.


That being said, the library isn't descriptive enough about what the error is, or how it was caused, so we will address this in a future update to the library.


Thanks,


Login or Signup to post a comment