1

I'm pretty new to submitting POST requests to API's using API credentials and am looking for an explanation on how it's done in Ruby on Rails.

I'm using the Shipwire API and am trying to POST to /orders.

POST /api/v3/orders HTTP/1.1
Host: api.beta.website.com
Authorization: Basic TG9vayBhdCB0aGF0OyBEdWNrcy4uLm9uIGEgbGFrZSEK

I have an Order object ready but am wondering if anyone could shed some light on this.

Corey Holmes
  • 368
  • 3
  • 13
  • What Rails library/gem are you using to make the API call? – Jeremie Apr 11 '17 at 03:03
  • 1
    How about `rest-client` https://github.com/rest-client/rest-client? Maybe you are looking for this: https://github.com/rest-client/rest-client#usage-activeresource-style. Also try this http://stackoverflow.com/questions/20890769/authentication-headers-using-rest-client-ruby-gem/20891526#20891526 – rony36 Apr 11 '17 at 04:26
  • Thank you very much! This is exactly what I was looking for :) – Corey Holmes Apr 11 '17 at 19:08

1 Answers1

1

Httparty gem will help you make any kind of ReST api requests. You will find lots of tutorials on how to perform basic auth using this gem. However, before jumping on code directly, i would suggest you to understand the request and response on the sandbox mode using the postman plugin for chrome.

Md. Farhan Memon
  • 6,055
  • 2
  • 11
  • 36