Question

I am trying to add a custom format for HAL (hypertext application language). I have my custom format handler created, I followed along with the ServiceStack v-card example, and all is working fine there and I was able to register it with ServiceStack.

The problem is that in my custom format I am trying to specify a content-type of "hal+json"

When I make a GET request to my service, and specify the format like so:

'http://mylocalserver:555555/items?format=hal+json'

ServiceStack defaults back to using just Json. I have tried changing the content type to something different like "halj" and ServiceStack formats requests that use "?format=halj" using my custom formatter fine.

I pulled down the source for ServiceStack and found that any request that comes in it checks the query string for a format, and if the format evens contains "json" it will default to the Json formatter.

Is there any way around this? I have been trying to find some documentation about how to override this behavior.

Was it helpful?

Solution

Unfortunately + is a special variable on a url. Try Url encoding it, e.g:

http://mylocalserver:555555/items?format=hal%2Bjson
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top