Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
Having a route like the following
from("timer:tick?period=3s").setBody().constant("foobar") .log("${body}") .process(exchange -> { final Message m = exchange.getMessage(); //m.setHeader("CamelGoogleSheets.valueInputOption", "RAW"); m.setHeader("CamelGoogleSheets.values", new ValueRange().setValues( Arrays.asList( Arrays.asList( m.getBody(String.class))))); }) .to("google-sheets://data/append?spreadsheetId={{google-sheets.spreadsheet-id}}&range=Sheet1!A1:A1");
results in the following exception unless one uncomments m.setHeader("CamelGoogleSheets.valueInputOption", "RAW"):
org.apache.camel.RuntimeCamelException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request POST https://sheets.googleapis.com/v4/spreadsheets/12dtOvsosJ4l1vIfLRqD8bZXyzLk0iGI4ENzN6qi_ys8/values/Sheet1!A1:A1:append { "code" : 400, "errors" : [ { "domain" : "global", "message" : "'valueInputOption' is required but not specified", "reason" : "badRequest" } ], "message" : "'valueInputOption' is required but not specified", "status" : "INVALID_ARGUMENT" } at org.apache.camel.component.google.sheets.GoogleSheetsProducer.doInvokeMethod(GoogleSheetsProducer.java:51) at org.apache.camel.support.component.AbstractApiProducer$1.run(AbstractApiProducer.java:89) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request POST https://sheets.googleapis.com/v4/spreadsheets/12dtOvsosJ4l1vIfLRqD8bZXyzLk0iGI4ENzN6qi_ys8/values/Sheet1!A1:A1:append { "code" : 400, "errors" : [ { "domain" : "global", "message" : "'valueInputOption' is required but not specified", "reason" : "badRequest" } ], "message" : "'valueInputOption' is required but not specified", "status" : "INVALID_ARGUMENT" } at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:428) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565) at org.apache.camel.component.google.sheets.GoogleSheetsProducer.doInvokeMethod(GoogleSheetsProducer.java:49) ... 7 more
It would be nice to document the header around here: https://camel.apache.org/components/latest/google-sheets-component.html#_api_data_method_append
Possible values are RAW and USER_ENTERED.
Also, I wonder whether the valueInputOption could be made an uri/component parameter, so that to("google-sheets://data/append?valueInputOption=RAW in DSL and camel.component.google-sheets.value-input-option=RAW in application.properties become possible?