Having a really strange issue but I'm not sure how to recreate the issue. My client has a woocommerce site using 2.5.5. When connecting using oauth, any request that I attempt to make from my server will get a 400 bad request.
After investigation into what causes this issue it seems like the culprit is:
def do_request method, endpoint, data = {}
url = get_url(endpoint, method)
options = {
format: :json,
verify: @verify_ssl,
headers: {
"User-Agent" => "WooCommerce API Client-Ruby/#{WooCommerce::VERSION}",
"Content-Type" => "application/json;charset=utf-8",
"Accept" => "application/json"
}
}
if @is_ssl
options.merge!(basic_auth: {
username: @consumer_key,
password: @consumer_secret
})
end
options.merge!(body: data.to_json) if data
HTTParty.send(method, url, options)
end
When it merges the data.to_json it seems to encode the body as "{}"
perhaps modifying the line to be
options.merge!(body: data.to_json) if data.present
will be a better approach since "{}" will always be truthy
Having a really strange issue but I'm not sure how to recreate the issue. My client has a woocommerce site using 2.5.5. When connecting using oauth, any request that I attempt to make from my server will get a 400 bad request.
After investigation into what causes this issue it seems like the culprit is:
When it merges the data.to_json it seems to encode the body as
"{}"
perhaps modifying the line to be
options.merge!(body: data.to_json) if data.present
will be a better approach since"{}"
will always be truthy