Failed to construct the request URI with Micronaut Http declarative client with Route Parameter

Viewed 55

Micronaut Declarative HttpClient is not working, throwing an exception as Unexpected error occurred: Client 'fetebirdProductApi': Failed to construct the request URI

Declarative Http Client

@Client(id="fetebirdProductApi", path = "/category/{categoryId}/sub-category")
public interface ISubCategoryClient extends ISubCategoryOperation {
}

Rest Controller

@Controller("/category/{categoryId}/sub-category")
public class SubCategoryController extends BaseController implements ISubCategoryOperation {
    
    public SubCategoryController(IServiceBus iServiceBus) {
        super(iServiceBus);
    }

    @Override
    public Mono<?> get(@ValidObjectId @NotNull @PathVariable(name = "categoryId") String categoryId) {
        return _iServiceBus.<SubCategoriesFindCommand, Mono<List<SubCategoryModel>>>send(new SubCategoriesFindCommand(categoryId))
                .onErrorMap(throwable -> {
                    throw new GlobalException(throwable);
                });
    }
}

Calling the HttpClient from one of the method

public class ApiGatewaySubCategoryController implements ISubCategoryOperation {
    private final ISubCategoryClient iSubCategoryClient;

    public ApiGatewaySubCategoryController(ISubCategoryClient iSubCategoryClient) {
        this.iSubCategoryClient = iSubCategoryClient;
    }

    @Override
    public Mono<?> get(@ValidObjectId @NotBlank @PathVariable String categoryId) {
        return this.iSubCategoryClient.get(categoryId);
    }
}


public interface ISubCategoryOperation {
    @Get("/")
    @Secured(SecurityRule.IS_ANONYMOUS)
    Mono<?> get(@ValidObjectId @NotNull @PathVariable(name = "categoryId") String categoryId);
}

Setting the Trace on the logback.xml file, no logs appear

<logger name="io.micronaut.http.client" level="TRACE"/>

Controller method never gets called.

The call always comes to the fallback

@Fallback
@Retryable(attempts = "3")
public class SubCategoryClientFallback implements ISubCategoryOperation {
    @Override
    public Mono<?> get(@ValidObjectId @NotBlank String categoryId) {
        return Mono.just(HttpResponse.serverError(ConstantValues.TAG_FALLBACK));
    }}

Exception

17:58:15.982 [default-nioEventLoopGroup-1-6] TRACE i.m.h.client.netty.DefaultHttpClient - ----

ERROR i.m.http.server.RouteExecutor - Unexpected error occurred: Client 'fetebirdProductApi': Failed to construct the request URI

Illegal character in path at index 10: /category/{categoryId}/sub-category?categoryId=631f08bf288259084b81ba36
0 Answers
Related