Hi Rico,

The problem seems to be with your usage of Curl which doesn't specify
the media type of your file. You probably need to set the
"Content-Type" header manually to "application/xml". This is the value
you will retrieve via "entity.getMediaType()".

The getVariants() method is only used for GET method calls, not for PUT.

Best regards,
Jerome


2007/11/3, Rico Hauke <[EMAIL PROTECTED]>:
> Hi list,
>
> I am trying to upload (put) .xml files to my restlet server via curl:
> curl -T <file.xml> http://<server>/<path>/<resource>.xml
>
> In my resource's constructor I set the supported media type via:
> getVariant().add(new Variant(MediaType.APPLICATION_XML));
>
> Unfortunately in my resource's put method, when I am trying to get the
> media type via getMediaType, it returns null:
>
> public void put (Representation entity)
> {
> if (entity.getMediaType().equals(MediaType.APPLICATION_XML)) {
> // throws NullPointerException because getMediaType returns null :(
> ...
> }
> }
>
> So I was wondering if I have to set the media type manually myself
> somewhere or what I am doing wrong that it doesn't get set correctly
> automatically?
>
> Thanks a lot,
> Rico
>

Reply via email to