How to set charset with wrapped resource?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to set charset with wrapped resource?

sandy320
This post has NOT been accepted by the mailing list yet.
This post was updated on .
There is an interface DirAttributeResource

    @Post("json")
    public void addEntry(PojoDirectoryEntry value);

The client resource to excute

DirAttributeResource connectionResource = clientResource.wrap(DirAttributeResource.class);
connectionResource.addEntry(data);

Got the exception Unsupported Media Type (415).

But when I used Firefox restclient console to send same request, it works well.

I capture these 2 http packages with wireshark and compare.
Found that the content-type in failed request header only has the application/json but no charset=utf-8

I have tried to add the below lines before addEntry(data), but useless:
        Representation entity = new StringRepresentation("",
                MediaType.APPLICATION_ALL_JSON, Language.DEFAULT,
                CharacterSet.UTF_8);
        clientResource.getRequest().setEntity(entity);

So my question is how to set the charset=utf-8 with wrapped resource class?