Closed TravisSperry closed 8 years ago
@TravisSperry yep, we need to encode that. Feel free to submit a Pull Request if you have some free time. I'll try fix it on the weekend.
It looks like they are being encoded in add_query_params... endpoint + URI.encode(flatten_hash(data).join('&')) Is the correct fix... URI.encode(endpoint + flatten_hash(data).join('&')) ?
The problem is actually in how the params are encoded for the oauth signature. Spaces aren't handled correctly. This happens regardless of whether you use a params hash or just pass a query_string. So the same problem occurs for
response = woocommerce.get("products?filter[category]=String+With+Spaces")
In oauth.rb, the encode_param method needs to be changed to:
CGI::escape(text).gsub('+', '%20').gsub("%", "%25")
I'll submit a pull request with the fix.
Thanks for the clarification.
Travis SperryDirector of IT
Math Plus Academy
O: 614.792.6284
C: 614.260.6162
Schedule a complimentary assessment:
http://www.mathplusacademy.com/book-assessment
On Wed, Dec 2, 2015 at 10:00 PM, Daniel Hoey notifications@github.com wrote:
The problem is actually in how the params are encoded for the oauth signature. Spaces aren't handled correctly. This happens regardless of whether you use a params hash or just pass a query_string. So the same problem occurs for response = woocommerce.get("products?filter[category]=String+With+Spaces") In oauth.rb, the encode_param method needs to be changed to: CGI::escape(text).gsub('+', '%20').gsub("%", "%25") I'll submit a pull request with the fix.
Reply to this email directly or view it on GitHub: https://github.com/woothemes/wc-api-ruby/issues/14#issuecomment-161501842
The following request... response = woocommerce.get("products", {'filter' => {'category' => 'String With Spaces'}}) Generates the following error... woocommerce_api_authentication_error Submitting the same request without spaces does not generate the error...I'm assuming this has to do with how the URL is built?