Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6588427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:02:49+00:00 2026-05-25T17:02:49+00:00

I am using Google Places API and trying to send a POST request to

  • 0

I am using Google Places API and trying to send a POST request to add a new place. But I keep getting a NullPointerException on the request.execute() part.

// Create POST body.
GenericData data = new GenericData();
GenericData coordinates = new GenericData();
coordinates.put("lat", latitude);
coordinates.put("lng", longitude);
data.put("location", coordinates);
data.put("accuracy", 50);
data.put("name", name);
JsonHttpContent content = new JsonHttpContent();
content.data = data;

// Send POST request.
HttpRequestFactory httpRequestFactory = LocationUtil.createRequestFactory(transport);
HttpRequest request = httpRequestFactory.buildPostRequest(new GenericUrl(GooglePlacesConsts.PLACES_REPORT_ADD_URL), content);
request.url.put("sensor", "false");
request.url.put("key", GooglePlacesConsts.API_KEY);
HttpResponse response = request.execute();

The code for createRequestFactory() is (this is from Davy’s Tech Blog):

public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
    return transport.createRequestFactory(new HttpRequestInitializer() {
        public void initialize(HttpRequest request) {
            GoogleHeaders headers = new GoogleHeaders();
            headers.setApplicationName("App Name");
            request.headers = headers;
            JsonHttpParser parser = new JsonHttpParser();
            parser.jsonFactory = new JacksonFactory();
            request.addParser(parser);
        }
    });
}

Is the code wrong? I kinda borrowed lines of codes from different sources, because I…don’t know how to correctly send a POST request in Java. Mainly, I followed the tutorial from Davy’s Tech Blog, but also tried to follow this post, because the previous link provided examples only for sending GET requests, and I need to send a POST request.

By the way, this is the stack trace:

javax.faces.FacesException: #{locationBean.actionAdd}: java.lang.NullPointerException
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 22 more
Caused by: java.lang.NullPointerException
    at com.google.api.client.http.json.JsonHttpContent.writeTo(JsonHttpContent.java:75)
    at com.google.api.client.http.apache.ContentEntity.writeTo(ContentEntity.java:56)
    at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:101)
    at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:107)
    at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:127)
    at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:253)
    at org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:218)
    at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:249)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
    at com.google.api.client.http.apache.ApacheHttpRequest.execute(ApacheHttpRequest.java:58)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:361)
    at model.location.LocationBean.actionAdd(LocationBean.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 23 more

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:02:49+00:00Added an answer on May 25, 2026 at 5:02 pm

    I struggled to find a version of that class that had a line number valid for your exception, but I found 1.4.1-beta.

    public void writeTo(OutputStream out) throws IOException {
        JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
        generator.serialize(data);
        generator.flush();
    }
    

    Line 45 is the first line of the method. So check that jsonFactory is not null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to request JSON from Google Places API, but I am still
I'm trying to call Google Places API 1 using jQuery but it seems to
I'm using Google Places API to retrieve data about places, but couldn't find how
I am trying to get Oauth working with the Google API using Python. I
I'm writing a web application using the google maps api v3, which displays places
We are trying a prototype using Google chart api. http://chart.apis.google.com/chart?chf=bg,s,000000&chxs=0,FFFFFF00,9.5&chxt=x&chs=500x300&cht=p3&chco=3072F3|FF9900|80C65A|990066&chd=t:50,5,5,40&chdl=50%C2%B0%20Apples|5%C2%B0%20Oranges|5%C2%B0%20Dates|40%C2%B0%20Strawberries&chdlp=b&chp=0.1 the problem is when
I'm trying to add markers to a map on my page using Google's Javascript
I am trying to make a website using Google API V3 to show your
am currently using google feed api to get feed links dynamically. am trying to
I currently using Google Places API for retrieving information for in a mobile application(iOS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.