wc-api-java not able to get woocommerce orders using before and after param

I want to get orders for the specific date but getting below error tried several date formates but getting the same error. This only happens when I am adding date parameters(before and after). This api works fine for per_page or without any param.

WooCommerce wooCommerce = new WooCommerceAPI(config, ApiVersionType.V3);
Map<String, String> params = new HashMap<>();

List<Map<String, Object>>  orders = wooCommerce.getAll(EndpointBaseType.ORDERS.getValue(), params);

This code is giving me an error Exception in thread “main” java.lang.RuntimeException: Can’t parse retrieved object: {code=woocommerce_rest_authentication_error, message=Invalid signature – provided signature does not match., data={status=401}}


I got the solution for the date issue here is the solution. we need to encode the dates.

params.put("after", percentEncode("01-01-2021T00:00:00"));

public String percentEncode(String s) {
        final String UTF_8 = "UTF-8";

        try {
            return URLEncoder.encode(s, UTF_8)
                    // OAuth encodes some characters differently:
                    .replace(SpecialSymbol.PLUS.getPlain(), SpecialSymbol.PLUS.getEncoded())
                    .replace(SpecialSymbol.STAR.getPlain(), SpecialSymbol.STAR.getEncoded())
                    .replace(SpecialSymbol.TILDE.getEncoded(), SpecialSymbol.TILDE.getPlain());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e.getMessage(), e);

Leave a Reply

Your email address will not be published. Required fields are marked *