Created
July 11, 2014 16:35
-
-
Save anggiaj/19c26610885596e88cd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'json' | |
URL = 'https://anggiaj.buddycloud.com/api' | |
conn = Faraday.new | |
conn.basic_auth 'thoriq@anggiaj.buddycloud.com', 'cencoredpassword' | |
res = conn.post "#{URL}/thoriq@anggiaj.buddycloud.com/content/posts", { content: 'Hello world' }.to_json, 'Content-type' => 'application/json' | |
# response body | |
{ | |
"id" => "1c58c2e9-8b79-48ab-8385-d578f9e30699", | |
"author" => "thoriq@anggiaj.buddycloud.com", | |
"published" => nil, | |
"updated" => nil, | |
"content" => "Hello world", | |
"media" => nil | |
} | |
# response header | |
{ | |
"date" => "Fri, 11 Jul 2014 16:28:58 GMT", | |
"server" => "Apache/2.4.9 (Ubuntu)", | |
"x-powered-by" => "Express", | |
"access-control-allow-origin" => "undefined", | |
"access-control-allow-credentials" => "true", | |
"access-control-allow-methods" => "GET, POST, PUT, DELETE", | |
"access-control-allow-headers" => "Authorization, Content-Type, X-Requested-With, X-Session-Id", | |
"access-control-expose-headers" => "Location, X-Session-Id", | |
"location" => "/thoriq@anggiaj.buddycloud.com/content/posts/tag:null@cs.buddycloud.com,/user/thoriq@anggiaj.buddycloud.com/posts,1c58c2e9-8b79-48ab-8385-d578f9e30699", | |
"content-type" => "application/json", | |
"content-length" => "155", | |
"cache-control" => "max-age=1", | |
"expires" => "Fri, 11 Jul 2014 16:28:59 GMT", | |
"connection" => "close" | |
} | |
# response status | |
201 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment