I'm using HTTParty to get data from the Eventbrite API.
response = HTTParty.get("https://www.eventbriteapi.com/v3/events/search?token=#{Figaro.env.eventbrite_oauth_token}")
I am trying to save an Event attachment to my object. (I'm using paperclip to upload images).
@event.image = "https://img.evbuc.com/http%3A%2F%2Fcdn.evbuc.com%2Fimages%2F18699100%2F162201087004%2F1%2Foriginal.jpg?h=200&w=450&rect=0%2C194%2C2000%2C1000&s=67649c6c8e7ef66e409189bf08474203"
But I get the error:
"OpenURI::HTTPError: 401 Unauthorized" with Rails, HTTParty, and Paperclip."
Any ideas on how to fix?
I've noticed in newer versions of Paperclip, I've needed to wrap any URL strings in URI.parse
when asking Paperclip to import the asset via URL.
So for your example:
@event.image = URI.parse("https://img.evbuc.com/http%3A%2F%2Fcdn.evbuc.com%2Fimages%2F18699100%2F162201087004%2F1%2Foriginal.jpg?h=200&w=450&rect=0%2C194%2C2000%2C1000&s=67649c6c8e7ef66e409189bf08474203")