Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid PlusClient writeMoment returns 400 response code
    primarykey
    data
    text
    <p>I am trying to use the PlusClient to write a location check-in using a "moment" on a Google+ user's profile. This is how I initialize the client:</p> <pre><code>mPlusClient = new PlusClient.Builder(this, this, this) .setVisibleActivities("http://schemas.google.com/AddActivity", "http://schemas.google.com/CheckInActivity") .setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE).build(); </code></pre> <p>Here is the onConnected:</p> <pre><code>public void onConnected() { //Log.d(tag,"onConnected()..."); googlePlusUserEmail = mPlusClient.getAccountName(); Log.d(tag, "googlePlusUserEmail = " + googlePlusUserEmail); } </code></pre> <p>After calling "mPlusClient.connect();" the connection is done successfully. I have a +1 button that works fine, and I have also managed to post on user's profile using the PlusShare:</p> <pre><code>String mapLing = "https://maps.google.com/maps?q=" + myLatitude + "," + myLongitude + "&amp;hl=en"; String description = "Hello!"; Intent shareIntent = new PlusShare.Builder() .setType("text/plain") .setText(description) .setContentUrl(Uri.parse(mapLing)) .getIntent(); startActivityForResult(shareIntent, 0); </code></pre> <p>However, if I have understand correctly I cannot "attach" an image with the PluShare, so I tried to use the Moments, like this:</p> <pre><code>String mapLing = "https://maps.google.com/maps?q=" + myLatitude + "," + myLongitude + "&amp;hl=en"; String description = "Hello!"; //build the item scope ItemScope checkInLocation = new ItemScope.Builder() .setId(googlePlusUserId) //do I need it? .setType("http://schema.org/Place") //tried also with "Thing" instead of Place, but no luck .setName(mOverlays.get(index).getSnippet() + " - " + mOverlays.get(index).getTitle()) .setUrl(mapLing) .setImage("http://www.mysite.com/images/icon.png") .setDescription(description) .build(); Moment moment = new Moment.Builder() .setType("http://schemas.google.com/CheckInActivity") .setTarget(checkInLocation).build(); if (mPlusClient.isConnected()) { Log.d(tag, "writeMoment..."); mPlusClient.writeMoment(moment); } </code></pre> <p>After checking <a href="https://stackoverflow.com/questions/16459215/google-android-api-plusclient-writemoment-is-doing-nothing">this</a> answer, I enabled the Verbose debug of GooglePlatform:</p> <pre><code>adb shell setprop log.tag.GooglePlusPlatform VERBOSE </code></pre> <p>Unfortunately, when I try to write the moment it returns this log:</p> <pre><code>05-22 01:08:01.908: E/Volley(3611): [29] il.a: Unexpected response code 400 for https://www.googleapis.com/plus/v1/people/me/moments/vault 05-22 01:08:01.918: D/GooglePlusPlatform(3611): Unexpected response code (400) when requesting: writeMoment 05-22 01:08:01.918: D/GooglePlusPlatform(3611): Error response: { 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "error": { 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "errors": [ 05-22 01:08:01.918: D/GooglePlusPlatform(3611): { 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "domain": "global", 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "reason": "invalid", 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "message": "Invalid Value" 05-22 01:08:01.918: D/GooglePlusPlatform(3611): } 05-22 01:08:01.918: D/GooglePlusPlatform(3611): ], 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "code": 400, 05-22 01:08:01.918: D/GooglePlusPlatform(3611): "message": "Invalid Value" 05-22 01:08:01.918: D/GooglePlusPlatform(3611): } 05-22 01:08:01.918: D/GooglePlusPlatform(3611): } </code></pre> <p>As I have also seen from <a href="https://stackoverflow.com/questions/15216550/google-plus-for-android-invalid-credentials">this</a> answer, it should not be a credentials problem, since I can successfully use the +1 and the PlusShare functions. I have also gone through the Google documentation <a href="https://developers.google.com/+/mobile/android/app-activities" rel="nofollow noreferrer">here</a> and specifically on the CheckInActivity <a href="https://developers.google.com/+/api/moment-types/checkin-activity" rel="nofollow noreferrer">here</a>, but still no luck. If anyone could have a suggestion on why the response is 400, it would be great.</p> <p><strong>EDIT1:</strong> After Scarygami's and Lee's suggestions below, I have tried to add the simplest moment using the following code:</p> <pre><code>ItemScope checkInLocation = new ItemScope.Builder() .setId("1234545") .setName("MyName") //.setUrl(mapLing) //link removed .setImage("http://www.mysite.com/images/icon.png") .setDescription("MyDescription") .setType("http://schema.org/Thing") .build(); Moment moment = new Moment.Builder() .setType("http://schemas.google.com/AddActivity") .setTarget(checkInLocation).build(); if (mPlusClient.isConnected()) { Log.d(tag, "writeMoment..."); mPlusClient.writeMoment(moment); Log.d(tag, "moment.getResult() = " + moment.getResult()); } </code></pre> <p>The good news is that the 400 error response code is gone :-), however nothing appears on my profile :-(. I'll work on it and update soon...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload