I am using mailgun to convert incoming emails to post requests for my rails app, and that part is working fine, but I also want to be able to retrieve stored messages from the mailgun messages API, and am having trouble accomplishing that. The docs for their messages api is:
To make things easier I installed the RestClient gem in my rails app and have hacked around with it in rails console, but cannot get the full email object to return.
EDIT - I can make a successful get request to the stored message URL using the Postman application, using basic authorization with 'api' for username and my api key for password. But when I try to make this request using the rest-client gem, it gives me a
url = 'https://se.api.mailgun.net/v3/domains/rest-of-the-url...'
user = 'api'
RestClient::Request.execute method: :get, url: url, username: user, password: secret
Not sure why it wasn't working before, but for anyone who's curious, this method using rest-client gem seems to do the trick!
url = [url of stored email] user = 'api' secret ='my-api-key' response = RestClient::Request.execute method: :get, url: url, user: user, password: secret email = JSON.parse(response.body) # the email object!