I have an API that expects/accepts in the body XML and can return json or XML. I’m trying to test this with rspec.
To make the request I do the following in my spec:
post "/resources?auth_token=#{@user.authentication_token}", post_data, {
"CONTENT_TYPE" => 'application/xml',
"ACCEPT" => 'application/json'
}
It works as expected until it gets to responding.It seems to be ignoring my ACCEPT header and returning an html document with a space as the body. I’ve tested the API using a restclient with the same headers and it works fine.
Is there something I’m missing here? On a side note… I can’t figure out how to print the request headers in the controller which could be useful.
Fixed!
I needed to use HTTP_ACCEPT for the accept header
i.e
Argh so annoying…