Closed lolucosmin closed 2 years ago
@eeatonaws Thanks for the reply. Ok lets take this: apiClient = new ApiClientFactory() .credentialsProvider(AWSMobileClient.getInstance()) .build(YOUR_API_CLIENT_NAME.class);
in my YOUR_API_CLIENT_NAME.class I have already this function: @com.amazonaws.mobileconnectors.apigateway.annotation.Operation(path = "/avatars", method = "GET") AvatarList avatarsGet();
in code example there they create a new request: ApiRequest localRequest = new ApiRequest(apiClient.getClass().getSimpleName()) .withPath(path) .withHttpMethod(HttpMethodName.valueOf(method)) .withHeaders(headers) .addHeader("Content-Type", "application/json") .withParameters(parameters); So is not make sense for me to create new request when that request is already defined in my YOUR_API_CLIENT_NAME.class. For me is not a good idea to create a new request for each function from my "YOUR_API_CLIENT_NAME.class", there are a lot of functions.
My workflow: this.myClient= new ApiClientFactory() .region(AppConfig.REGION.getName()) .endpoint(AppConfig.SERVER_TICKETS_ENDPOINT) .clientConfiguration(this.clientConfiguration) .credentialsProvider(provider) .build(MyClient.class); and on async or observer I run: myClient.avatarsGet()
Hi @lolucosmin, thanks for the additional information. The parameter annotation, with the location set to "header", can be used to specify headers that should be added to the request, but the value for each header would need to be passed as a parameter to the method. Are there any restrictions on your use case that would prevent you from passing the header values as parameters to the method?
State your question There is a way to add custom headers before call: apiCLient.methodX . ?
Which AWS Services are you utilizing?
Provide code snippets (if applicable)
and when I do a request I call:
Environment(please complete the following information):
Device Information (please complete the following information):
If you need help with understanding how to implement something in particular then we suggest that you first look into our developer guide. You can also simplify your process of creating an application, as well as the associated backend setup by using the Amplify CLI.