tcl - How to PUT xml content using method ::http::geturl -method PUT -
when tried fire fox open httprequest addon, able 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 trying simulate same operation tcl put method http package, 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 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
 @ [row,col {unknown-source}]: [1,0]
 @ org.apache.wink.common.internal.providers.entity.xml.jaxbxmlprovider. readfrom(jaxbxmlprovider.java:113)
 @ org.apache.wink.server.internal.registry.serverinjectablefactory$enti typaram.getvalue(serverinjectablefactory.java:190)
i not sure missing, 1 please resolve issue.
thanks
to send xml document in request via put, assuming you've got document serialized string obtainable $thexml
, this:
# type *might* need text/xml http::geturl $theserviceurl -method put -type application/xml -query $thexml
of course, you've got make sure handle token returns right, , on. http
package still pretty low-level. (for example, you'll have use http::config
set mime types in response, , you'll need handle redirects , cookies sessions yourself.)
sending json instead? type becomes application/json
. easy!
Comments
Post a Comment