Post from Java to a Google docs form


A working example : sending a request to a Google doc form with okhttp.

Create a form:

Add a question:

See the form once done:

You have to find the name of your inputs by looking at the source code of the form, the name starts with entry. following by a number:

<input name="entry.361168075" value="" class="ss-q-short" id="entry_361168075" dir="auto" aria-label="What's your favorite color  " aria-required="true" required="" title="" type="text">

Write a small program:

import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class Test {

  public static void main( String[] args ) {
    try {
      OkHttpClient client = new OkHttpClient();
      FormBody body = new FormBody.Builder()
          .add( "entry.361168075", "Red" )
      Request request = new Request.Builder()
          .url( "" )
          .post( body )
      Response response = client.newCall( request ).execute();
      System.out.println( response.isSuccessful() );

    catch ( Exception e ) {

And see the result in the spreadsheet output:


Android, NodeJS, Openshift, Twilio
3 minutes Icescrum server with docker on Debian Jessie

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.