I am trying to send a get request to the url https://www.googleapis.com/groups/v1/groups/"+group_id where group id is a unique group id i am expecting to get a response which will describe setting of a group but instead i get the response
{ "error": { "errors": [ { "domain": "global", "reason": "authError", "message": "Domain cannot use Api, Groups service is not installed.", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Domain cannot use Api, Groups service is not installed." } }
I enabled my group settings api in my project api and group services is turned on in my domain can any one please tell why i am getting this error and how to get rid of this error??i am using google apps for business edition free trial. here is my code of java for sending get request in java
package org.ritesh;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Group_Detail extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse resp){
resp.setContentType("text/HTML");
String access_token=req.getParameter("access_token");
String group_id=req.getParameter("group");
String url="https://www.googleapis.com/groups/v1/groups/"+group_id+"?alt=json";
URL ur;
try {
ur = new URL(url);
HttpURLConnection conn=(HttpURLConnection) ur.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "OAuth "+access_token);
InputStream str= conn.getInputStream();
BufferedReader reader=new BufferedReader(new InputStreamReader(str));
String l="";
resp.getWriter().println("<html><head>Group Detail</head><body>");
while((l=reader.readLine())!=null)
{resp.getWriter().println(l);
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I am getting access_token and groupid in request parameter and they are correct for sure.
i enabled group service few minutes before asking this question when i tried this code after 45 minutes this was working fine