Open igorkasyanchuk opened 1 year ago
This query_card
method (and other methods with export_format
) does not seem to work by its definition.
Metabase API expects to receive data as a url encoded form and this gem sends this request body as a json.
The way to solve this would be (lib/metabase/connection.rb:33):
encoded_body = params.delete(:encoded_body)
response = connection.public_send(method, path, params) do |request|
request.headers['X-Metabase-Session'] = @token if @token
headers&.each_pair { |k, v| request.headers[k] = v }
request.body = encoded_body if encoded_body
end
Now you can just do
encoded_params = URI.encode_www_form({ parameters: params.to_json }).gsub('+', '%20')
client.query_card(
CARD_ID,
format: :json,
encoded_body: encoded_params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
)
and get the correct response.
I may do the PR later if I'll get a chance (just because it also requires to update specs and the readme)
Want to get card data. Found one solution. But want to ask if there is a proper way?
AND
in
lib/metabase/connection.rb
comment one line