Giter VIP home page Giter VIP logo

Comments (3)

xsalefter avatar xsalefter commented on June 5, 2024

I get the same problem as well. Calling the woo-commerce endpoint via CURL is fine, for example:

curl "https://www.mysite.com/wp-json/wc/v2/orders?after=2021-01-01T00:00:00.000Z&before=2021-01-20T00:00:00.000Z" -u key:secret;

Furthermore, using this parameters is working like a charm as well:

// params.put("after",  "2021-02-01T00:00:00.000Z");
        // params.put("before", "2021-02-13T00:00:00:000Z");
        params.put("context", "view");
        params.put("per_page", "20");
        params.put("page", "1");
        params.put("status", "any");
        params.put("orderby", "title");

Only when we uncomment one of before or after, then we get the exception described in this issue. Maybe there's little things that missing here.

@omandryk (sorry for mentioned you here), but do you have any idea what's going on?

from wc-api-java.

kiranuw avatar kiranuw commented on June 5, 2024

Issue Fixed. Got the solution we need to encode the dates.

String wcFormattedDate=startDate+"T00:00:00";
			Map<String, String> params = new HashMap<>();
			params.put("per_page", "10");
			params.put("after", percentEncode(wcFormattedDate));

	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);
		}
	}


from wc-api-java.

xsalefter avatar xsalefter commented on June 5, 2024

@kiranuw I think this issue should not closed yet, as currently there's PR from me about this issue.

from wc-api-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.