•   over 5 years ago

500 error

Anybody tried to get translate the cashtie curl http post request example into ruby? I attempted using net/http and the gems Typhoeus and HTTParty but I keep getting 500 errors. I am new to this so any examples would be highly appreciated.

curl -X POST https://testapi.cashtie.com/accounts -H 'Authorization: Token token="some_token"' -H 'Accept: application/vnd.cashtie.com+json; version=1' -H 'Content-Type: application/json' -d '{ "account": { "settings": { "payments": { "amount": { "fixed": 10.99 } }, "upc": "TEST00000000" } } }'

  • 3 comments

  •   •   over 5 years ago

    Gustavo - just saw this. Team will answer for you. For future support requests always use support@cashtie.com

  •   •   over 5 years ago

    Gustavo, please try the snippet below:

    require 'net/https'

    url = URI.parse('https://testapi.cashtie.com/accounts')
    req = Net::HTTP::Post.new(url.path)
    req.body ='{ "account": { "settings": { "payments": { "amount": { "fixed": 10.99 } }, "upc": "TEST00000000" } } }'
    req['Authorization'] = 'Token token="some_token"'
    req['Accept'] = 'application/vnd.cashtie.com+json; version=1'
    req['Content-Type'] = 'application/json'

    res = Net::HTTP.new(url.host, url.port)
    res.use_ssl = true
    res.verify_mode = OpenSSL::SSL::VERIFY_PEER
    res.start { |http| http.request(req) }

  •   •   over 5 years ago

    Thank you Thomas and Andrii! The example above will serve as a great piece of reference for when I update the CrowdFundedRecommender application.

Comments are closed.