Send audio file to Make.com webhook, getting 502 cloudflare error

Hello,

I am trying to send mp3 file data to my Make.com webhook, in order to then upload it to the OpenAI module to be transcribed via the Whisper model.

I’m sending the data via a ruby script. If I send text to the webhook it works fine, so I am sure that the connection and the script is working. However if I send the actual audio file data, I get a 502 Bad Gateway error from Cloudways. The request never arrives to the make.com scenario.

This is what I get back as a response:

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

What can I do about this? I assume it must be cloudflare protection that Make.com is using. The file I am sending is only 10MB and will never exceed 25MB as that is the OpenAI API limit, so I’m not sure what the problem might be. Thanks for any advice.

The relevant ruby code (if it matters) is as follows:

def send_audio_file_to_make(temp_file, lecture, max_retries = 3)
  puts "send_audio_file_to_make"
  url = "https://hook.us1.make.com/[redacted]"
  uri = URI.parse(url)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = (uri.scheme == 'https')

  request = Net::HTTP::Post.new(uri.path)

  boundary = "RubyFormBoundary#{rand(1000000)}"
  request['Content-Type'] = "multipart/form-data; boundary=#{boundary}"

  # Read the file and create the body
  post_body = []
  post_body << "--#{boundary}\r\n"
  post_body << "Content-Disposition: form-data; name=\"audio\"; filename=\"audio.mp3\"\r\n"
  post_body << "Content-Type: audio/mpeg\r\n\r\n"
  post_body << temp_file.read
  post_body << "\r\n--#{boundary}--\r\n"
  
  request.body = post_body.join


  retries = 0
  begin
    
    # Send the request
    response = http.request(request)

Thanks for any help!

The maximum allowed webhook’s payload size (Content-Length) is 5 MB.

For more information on webhook limits, see Webhook and its limitations - #2 by samliew

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

1 Like

Thanks - I realised in the end the issue was the format coming out of Ruby was indeed incorrect

2 Likes