mikespook / wc-api-golang

A Golang wrapper for the WooCommerce API.
MIT License
7 stars 11 forks source link

Doesnt encode spaces in URL correct #4

Closed pitw closed 6 years ago

pitw commented 6 years ago

Example:

param := url.Values{} param.Set("sku","Some Article with space") rc, err := client.Get("products", param)

This example will replace spaces with "+" instead of "%20".

Reason for this is somewhere here: https://github.com/mikespook/wc-api-golang/blob/2ac125e0c76c01d965366bf33379a9d57abe7457/woocommerce/client.go#L97

mikespook commented 6 years ago

"+" is not a standard of url encoding. We need a further research to see how wc handles a space in sku.

pitw commented 6 years ago

Reason is explained here quite well: https://play.golang.org/p/pOfrn-Wsq5

Looks like they got same problem here: https://github.com/woocommerce/wc-api-ruby/commit/31f086fb3d61948886b1dcae32a686ec77b29478

Although if I try similar approach and replace all "+" with "%20" I always get "woocommerce_rest_authentication_error" because of invalid oauth signature.

pitw commented 6 years ago

Issue solved in my fork (solves also problem with German Umlauts): https://github.com/pitwch/wc-api-golang/blob/b7cf3f7b9f201974d8d635f45f2965d218dd62d5/woocommerce/client.go#L106