0

I want to POST request, using Ruby gem Faraday. Content-Type is "application/pdf".

my code is below.

    client = Faraday.new(endpoint) do |client|
      client.request :retry
      client.headers['Content-Type'] = "application/pdf"
      client.headers['Authorization'] = auth_token
      client.adapter Faraday.default_adapter
    end

    response = client.public_send(:post, endpoint, params)

but, I got Error.

undefined method `bytesize' for {:title=>"0722 14 ID:14"}:Hash

Please Help me.

  • `bytesize` is a method from `String` – it seems that you are passing a hash instead of a string somewhere. Any idea what that `{:title=>"0722 14 ID:14"}` is? Maybe this is supposed to be a JSON payload and you forgot to convert the hash to JSON? (just guessing) – Stefan Jul 22 '22 at 11:13
  • What is `params`? Please provide a [mcve]. – Tom Lord Jul 22 '22 at 12:33

0 Answers0