woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 73 forks source link

JSON Parse Error on GET #33

Closed nikgoy closed 7 years ago

nikgoy commented 7 years ago

Hi,

I am getting a JSON Error for any type of request that I'm making. I have tested the same on C9 as well as my local dev machine. I also tried more than one woocommerce installation yet the issue still persists?

/Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/json-2.0.2/lib/json/common.rb:156:in `parse': 743: unexpected token at '{"code":"woocommerce_rest_authentication_error","message":"Invalid timestamp.","data":{"status":401}}' (JSON::ParserError)
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/json-2.0.2/lib/json/common.rb:156:in `parse'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/parser.rb:118:in `json'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/parser.rb:138:in `parse_supported_format'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/parser.rb:105:in `parse'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/parser.rb:67:in `call'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/request.rb:345:in `parse_response'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/request.rb:297:in `block in handle_response'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/response.rb:25:in `parsed_response'
    from /Users/nikhilgoyal/.rvm/gems/ruby-2.3.3@nik/gems/httparty-0.14.0/lib/httparty/response.rb:74:in `respond_to?'
    from test.rb:20:in `puts'
    from test.rb:20:in `puts'
    from test.rb:20:in `<main>'

UPDATE:

After testing continuously I found that this issue is being caused by the SMART COUPONS (https://woocommerce.com/products/smart-coupons/) plugin. Also I would like to add that Woocommerce API is working fine in a REST client like POSTMAN. Also I would like to add that Woocommerce API when working with Ruby REST Client like https://github.com/rest-client/rest-client The main problem appears to be how HTTParty is using JSON to parse. I think thats the issue. I am working on a way around this to make this work. In the meantime I would request the plugin author to shed some light, as I am not a very well versed programmer.

nikgoy commented 7 years ago

35

claudiosanches commented 7 years ago

JSON Parse Error on GET

This error is generally caused by some PHP warning that you site should not be displayed since it is a security flaw. Just fix all PHP warning and notices that will start work again.