Forcing "Accept: application/json" in request header?


#1

Hopefully a silly question - I see how to set "mediaType: “application/json” which I have and I see how to assume XML vs. json in the response body but I’m unsure and can’t find a reference to how to get the “accept” property in the request header set when using the “try it” testing against a local service install - the service I’m testing against (not mine) assumes XML response by default and the only way to get it to respond back with json is to set the Accept: header in the request - is there a simple property to set to make this happen?
thanks


#2

Hi Jeff, I haven’t seen that as well. Which browser are you using? In firefox you can easily change the default “accept” header or use browser extensions like Postman for Chrome. In the meanwhile let me check if you can change it for the “try it” feature. I will come back to you later.


#3

Yeah, I use Postman when testing locally and it’s no problem there - I wanted to share the link to the RAML definition I’m working on to describe an existing shipping product’s API to external folks and have it communicate with my local install of the server - so I wanted to get/post/delete commands to work via the “try it” link so they can play - trying to convince the powers that be that standardizing on this format for all our API definitions across all products is a good direction to go by “wowing” them with what we can expose to external developers as we go - which I think is a very cool thing… just need to nail down the ability to force a JSON response first…

thanks for looking into it.


#4

I have this requirement too. I can’t seem to pre-define a default header value that gets passed through to “try it”. I noticed there’s a ‘default’ parameter but that seems to get ignored.


#5

I think this is quite linked to http://forums.raml.org/t/static-headers/509/3 right @carl_bourne?


#6

Yes - it is the same question/issue.