Peter Palaga created CAMEL-18078:
------------------------------------
Summary: CamelGoogleSheets.valueInputOption not documented for
google-sheets://data/append
Key: CAMEL-18078
URL: https://issues.apache.org/jira/browse/CAMEL-18078
Project: Camel
Issue Type: Improvement
Components: google-sheets
Reporter: Peter Palaga
Having a route like the following
{code}
from("timer:tick?period=3s").setBody().constant("foobar")
.log("${body}")
.delay(1000) // othewise new record sometimes overwrites the
last record in the sheet
.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)))));
})
{code}
.to("google-sheets://data/append?spreadsheetId={{google-sheets.spreadsheet-id}}&range=Sheet1!A1:A1");
{code}
results in the following exception unless one uncomments
{{m.setHeader("CamelGoogleSheets.valueInputOption", "RAW")}}:
{code}
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
{code}
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?
--
This message was sent by Atlassian Jira
(v8.20.7#820007)