function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Subbu'sSubbu's 

Need Help in Integrating Google+

Hi Everybody ,

 

I am trying to make a HTTP request to Google+ Moments Insert method ..by taking the reference as below link.

https://developers.google.com/+/api/latest/moments/insert

 

Here is  the code  used ..

 

      Http httpm = new Http ();
      HttpRequest httpReqm = new HttpRequest();
      HttpResponse httpResm = new HttpResponse();
      httpReqm.setMethod('POST');
      String EndPointURL1 = 'https://www.googleapis.com/plus/v1/people/me/moments/vault';
      httpReqm.SetEndpoint(EndPointURL1);
     // String AuthHead = tokenType + ' '+AccessToken ;  
      httpReqm.setHeader('Authorization',AuthHead);
     httpReqm.setBody('{
                                             "Type"   : "http://schemas.google.com/AddActivity" ,
                                             "target" : {
                                                                "tragetURL" : "https://developers.google.com/+/plugins/snippet/examples/thing"
                                                             }
                                        }');
      httpResm = httpm.send(httpReqm);

 

I am Getting the response ..as

 

{ "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "This API does not support parsing form-encoded input." } ], "code": 400, "message": "This API does not support parsing form-encoded input." } }.

 

Also,I was used scope as they mentioned in the API above .

 

Can anyone plz clarify me how to set the Request body for this request. and get the proper response.

vbsvbs

@Subbu - Can you try setting the HTTP header to 'application/json'. The other thing i see missing based on the API is the "collection" part of the URI which is expect is required. Once you are further down the line debugging I can see a potential issue with the JSON string as well. The below should be changed from:

 "target" : {
     "tragetURL" : "https://developers.google.com/+/plugins/snippet/examples/thing"
  }

to

 "target" : {
     "url" : "https://developers.google.com/+/plugins/snippet/examples/thing"
  }

 

This is based on the API documentation as I do not see a targetURL attribute for the target object in the JSON request.

 

Regards

 

 

 

 

 

Subbu'sSubbu's

Hii Vbs , 

 

Thanx for your reply . Now I was clear about the request to make .

 

Now  I can able to get the response for all other methods except for moments.Insert method ,always  it showing the response as below ..

{

  • "error":{
    • "errors":[
      • {
        • "domain":"global",
        • "reason":"unauthorized",
        • "message":"Unauthorized"
        }
      ],
    • "code":401,
    • "message":"Unauthorized"
    }

}

 

In the API documentation they mentioned as this method will not work in the explorer..

plz refer the NOTE in this link    https://developers.google.com/+/api/latest/moments/insert.

 

Can u clarify is this my problem or any thing other ?

vbsvbs
This looks like an issue with authorizing the request. There are 2 ways to do this:
1. Use the API key provided with your Google developer account and pass this as a query parameter key=yourAPIKey with your GET request.
2. Use OAuth2 for getting access to the resource and use the token to complete your request.
See this https://developers.google.com/+/api/oauth to manage your authentication process.