When i tried with Fire Fox Open HttpRequest Addon, i was able to put sucessfully.
PUT http://12.222.20.17:8080/qcbin/rest/domains/test/projects/runtest/runs/385762
Accept: application/xml
Content-Type: application/xml
<Entity Type="run">
<Fields>
<Field Name="status">
<Value>Passed</Value>
</Field>
</Fields>
</Entity>
-- response --
200 OK
Server: Apache-Coyote/1.1
But i am trying to simulate same operation with TCL PUT method http package, i am getting Bad Request response
set xml {<Entity Type="run"><Fields><Field Name="status"><Value>Passed</Value></Field></Fields></Entity>}
set Headers(Cookie) $cookie
set Headers(Accept) "application/xml"
set Headers(Content-Type) "application/xml"
set Headers(Content) $xml
set token [::http::geturl "http://12.222.20.17:8080/qcbin/rest/domains/test/projects/runtest/runs/385762" -method PUT -headers [array get Headers]]
Response
% ::http::data $token
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><QCRestException><Id>qcco
re.general-error</Id><Title>Bad Request</Title><StackTrace>javax.ws.rs.WebApplic
ationException: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]
at org.apache.wink.common.internal.providers.entity.xml.JAXBXmlProvider.
readFrom(JAXBXmlProvider.java:113)
at org.apache.wink.server.internal.registry.ServerInjectableFactory$Enti
tyParam.getValue(ServerInjectableFactory.java:190)
I am not sure where i am missing, could some one please help to resolve this issue.
Thanks
To send an XML document in your request via PUT, assuming you've got the document serialized into a string obtainable with $theXML
, you just do this:
# Type *might* need to be text/xml
http::geturl $theServiceURL -method PUT -type application/xml -query $theXML
Of course, you've got to make sure that you handle the token that it returns right, and so on. The http
package is still pretty low-level. (For example, you'll probably have to use http::config
to set what MIME types you get in the response, and you'll need to handle redirects and cookies for sessions yourself.)
Sending JSON instead? The type then becomes application/json
. Easy!