0

I want to add a parameter to the Cloud Tasks that can then be retrieved from the Task handler using:

request.getParameter("paramName");

Previously in App Engine Standard I would do the following:

TaskOptions options = TaskOptions.Builder.withUrl(backURL)
                .param("paramName", "value")
                .method(Method.POST);

How do I accomplish the same using the Cloud Tasks java client library. It seems like in the AppEngineHttpRequest builder there should be a setParameter option but that doesn't exist.

AppEngineHttpRequest request = AppEngineHttpRequest.newBuilder()
                .setRelativeUri(backURL)
                .setHttpMethod(HttpMethod.POST)
                .build();
4

1 回答 1

3

Looking at the article called HTTP Target tasks we see an example of building a task in Java. Within the configuration, we see two primary setters .. namely body and url. I am thinking that what you are wanting to set are request query parameters. If this were a plain request it would be:

https://somehost.com/somepath?someParam=someValue

If this holds, then it is likely that if you want to pass in query parameters with your task, you would add them to the uri used to invoke the task handler.

于 2019-11-16T06:27:25.600 回答