Hi to all,
I'm getting the same 400 Bad Request Error when I'm trying to call the search method on profiles.
Here's the code I'm using:
Code:
LinkedInTemplate template = createLinkedInTemplate(request);
List<LinkedInProfile> connections = template.connectionOperations().getConnections();
for (LinkedInProfile linkedInProfile : connections) {
System.out.println(linkedInProfile.getSummary());
}
List<Company> companies = template.companyOperations().getFollowing();
for (Company company : companies) {
System.out.println(company.getDescription());
}
SearchParameters searchParams = new SearchParameters();
searchParams.setKeywords("java");
searchParams.setPostalCode("75001");
searchParams.setSort(Sort.RECOMMENDORS);
SearchResultPeople searchRes = template.profileOperations().search(searchParams);
List<LinkedInProfile> searchPeople = searchRes.getPeople();
for (LinkedInProfile linkedInProfile : searchPeople) {
System.out.println("::Proposition " + linkedInProfile.getFirstName() + " " + linkedInProfile.getLastName() + " -> " + linkedInProfile.getSummary());
}
The first two api calls, getting the connections of a logged in user and companies that the user follows work like a charm but the search isn't.
I'm getting the following error:
Code:
[INFO] WARN : org.springframework.web.client.RestTemplate - GET request for "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary,api-standard-profile-request))?&keywords=java&&postal-code=75001&start=0&count=10&sort=recommendors" resulted in 400 (Bad Request); invoking error handler
[INFO] ERROR: rs.co.neotech.server.SemsegServer - Exception caught by aspect: 400 Bad Request
[ERROR] org.springframework.web.client.HttpClientErrorException: 400 Bad Request
[ERROR] at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
[ERROR] at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
[ERROR] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
[ERROR] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
[ERROR] at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
[ERROR] at org.springframework.social.linkedin.api.impl.ProfileTemplate.search(ProfileTemplate.java:87)
[ERROR] at rs.co.neotech.server.SemsegServiceImpl.linkedInLogin_aroundBody26(SemsegServiceImpl.java:200)
[ERROR] at rs.co.neotech.server.SemsegServiceImpl$AjcClosure27.run(SemsegServiceImpl.java:1)
[ERROR] at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
[ERROR] at rs.co.neotech.server.aspectj.SemsegAspects.doRpcCall(SemsegAspects.java:103)
[ERROR] at rs.co.neotech.server.SemsegServiceImpl.linkedInLogin(SemsegServiceImpl.java:180)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at org.gwtwidgets.server.spring.GWTRPCServiceExporter.invokeMethodOnService(GWTRPCServiceExporter.java:169)
[ERROR] at org.gwtwidgets.server.spring.GWTRPCServiceExporter.processCall(GWTRPCServiceExporter.java:338)
[ERROR] at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
[ERROR] at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[ERROR] at org.gwtwidgets.server.spring.GWTRPCServiceExporter.handleRequest(GWTRPCServiceExporter.java:407)
[ERROR] at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
[ERROR] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
[ERROR] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
[ERROR] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
[ERROR] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
[ERROR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[ERROR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[ERROR] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[ERROR] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
[ERROR] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[ERROR] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[ERROR] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[ERROR] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
[ERROR] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR] at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
[ERROR] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR] at org.mortbay.jetty.Server.handle(Server.java:324)
[ERROR] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[ERROR] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
[ERROR] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
[ERROR] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
[ERROR] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[ERROR] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
[ERROR] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
As I can see your HTTP builder is behaving strange as it adds & before the keywords in the uri and also after the keywords it adds one extra &.
Is it me who doesn't know how to create the SearchParameters object or is there something else? I haven't found any documentation on how the query should be built.
Thanks in advance!