Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove .xml extension from ActiveResource request

I am trying to use ActiveResource to consume xml data from a third party API. I can use the RESTClient app to successfully authenticate and make requests. I coded my app and when I make a request I get a 404 error. I added:

ActiveResource::Base.logger = Logger.new(STDERR) 

to my development.rb file and figured out the problem. The API responds with xml data to requests that do NOT end in xml. EG, this works in RESTClient:

https://api.example.com/contacts

but ActiveResource is sending this request instead

https://api.example.com/contacts.xml

Is there anyway "nice" way to strip the extension from the request being generated by ActiveResource?

Thanks

like image 214
Matt Avatar asked Jul 21 '10 15:07

Matt


1 Answers

You can exclude the format string from paths with:

class MyModel < ActiveResource::Base
  self.include_format_in_path = false
end
like image 129
Björn Albers Avatar answered Sep 25 '22 22:09

Björn Albers