Skip to content

Instantly share code, notes, and snippets.

@did
Created July 21, 2014 13:59
Show Gist options
  • Save did/725202d5f4417cbbbc72 to your computer and use it in GitHub Desktop.
Save did/725202d5f4417cbbbc72 to your computer and use it in GitHub Desktop.
LocomotiveCMS API Example
require 'httparty'
require 'locomotive/mounter'
$api_base_url = ""
$api_key = ""
Locomotive::Mounter::EngineApi.set_token(uri: "http://#{$api_base_url}/locomotive/api", api_key: api_key)
attributes = {
title: 'Hello world',
description: 'Lorem ipsum'
image: File.new('my_image.png')
}
query = { query: { 'content_entry' => attributes } }
response = Locomotive::Mounter::EngineApi.post("/content_types/articles/entries.json", query)
if response.success?
puts "article created"
else
puts "failed to create an article"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment