# Upload Files to FM 17 Data API with ruby

**URL:** <https://the.fmsoup.org/t/upload-files-to-fm-17-data-api-with-ruby/1764>\
**Category:** Questions\
**Tags:** data-api\
**Created:** [February 25, 2021, 12:10pm UTC](https://the.fmsoup.org/t/upload-files-to-fm-17-data-api-with-ruby/1764 "2021-02-25T12:10:27Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://the.fmsoup.org/u/christian)\
**Post date:** [February 25, 2021, 10:08pm UTC](https://the.fmsoup.org/t/upload-files-to-fm-17-data-api-with-ruby/1764/6 "2021-02-25T22:08:36Z")

</div>

Thanks Monkeybread!

I sent the post request to a different app and saw that the library i used `Ruby/HTTParty` didnt send the body because multipart is [not supported](https://www.rubyguides.com/2018/08/ruby-http-request/).  
I switched to [Faraday](https://rubygems.org/gems/faraday) and now it works well.

For the case it may help someone, here is the code

```auto
url = "https://rocky.datenbank-hosting.com/fmi/data/v1/databases/rocky/layouts/#{layout}/records/#{fm_id}/containers/#{container_field_name}/1"
 ur = URI.parse(url)
      conn = Faraday.new(url, headers: { authorization: "Bearer #{@token}" }) do |f|
        f.request :multipart
        f.request :url_encoded
        f.adapter :net_http
      end
      payload = { :upload => Faraday::UploadIO.new(file_path, 'image/jpeg') }
      response = conn.post(ur.path, payload)

```

**I spent days with this!**  
Gems i tried that are not working for me:

- FmRest (Beezwax) =\> could not create any record, and i found it more helpful to go more to the root-libraries
- directly `CURL` inside ruby =\> that is too much root 🙂 possible, but at the end you want to have a wrapper, that is more convenient
- Multipart-Post =\> workes fine, but not for FileMaker
- and some others 🙂

---

_[View the full topic](https://the.fmsoup.org/t/upload-files-to-fm-17-data-api-with-ruby/1764)._
