Question

This is my curl command which works nicely in Command line :

curl --data @order_new.json \
     -H "X-Augury-Token:My_token_goes_here" \
     -H "Content-Type:application/json" \
     http://staging.hub.spreecommerce.com/api/stores/store_id_goes_here/messages

I need to implement the same in rails using any sort of Gem, Tried with HTTParty /rest_client / spree-api-client, but something wrong here :

require 'httparty'

result = HTTParty.post(
        "http://staging.hub.spreecommerce.com/api/stores/52eb347f755b1c97e900001e/messages",
        :body => JSON.parse(File.read("order_new.json")),
        :header => {
           "X-Augury-Token" => "UjjKsdxbrwjpAPx9Hiw4",
           "Content-Type" => "application/json" 
        }
)

But I am getting Error,

"The page you were looking for doesn't exist (404)"

I need rails equivalent of above curl command, use of spree-api-client gem will be much helpful.

No correct solution

OTHER TIPS

If you prefer to use the Spree::API::Client, could you post the results of your findings? Could you evaluate the output of the following commands and post back:

client = Spree::API::Client.new('http://staging.hub.spreecommerce.com/api/', 'UjjKsdxbrwjpAPx9Hiw4')
client.products.inspect
require 'httparty'

result = HTTParty.post(
        "http://staging.hub.spreecommerce.com/api/stores/52eb347f755b1c97e900001e/messages",
        :body => @order.to_json,
        :header => {
           "X-Augury-Token" => "UjjKsdxbrwjpAPx9Hiw4",
           "Content-Type" => "application/json" 
        }
)

Don't parse json while passing to HTTParty body

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top