3

I´m trying to use Fusiontables.Table.ImportRows to import a csv-file into my fusion-table. But I´m getting a NullPointerException with no additional information when I´m running execute().

I`m using the FusionOAuth2-sample-code and implemented an additional method:

private static void importRows(final String tableId){
 try {

  final String text = "Text,Number,Location\n" +
   "company,13,my street 14";

  final ByteArrayContent byteArrayContent = ByteArrayContent.fromString("text/comma-separated-values", text);
  final Fusiontables.Table.ImportRows importRows = fusiontables.table().importRows(tableId, byteArrayContent);
  importRows.setEncoding("UTF-8");
  importRows.execute();
 } catch (IOException e) {
  e.printStackTrace();
 } catch (NullPointerException e) {
  e.printStackTrace();
 }
}

This is the Exception:

java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3003)
at java.net.URI.<init>(URI.java:578)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:100)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:269)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:408)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:328)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:449)
at com.google.api.services.samples.fusiontables.cmdline.FusionTablesSample.importRows(FusionTablesSample.java:185)

What am I missing?

4

1 回答 1

0

您是否更改了初始化 fusiontables 对象的方式(com.google.api.services.fusiontables.Fusiontables 之一)?

于 2012-12-07T20:24:50.130 回答