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&#xd;   @ [row,col {unknown-source}]: [1,0]&#xd;         @ org.apache.wink.common.internal.providers.entity.xml.jaxbxmlprovider. readfrom(jaxbxmlprovider.java:113)&#xd;         @ org.apache.wink.server.internal.registry.serverinjectablefactory$enti typaram.getvalue(serverinjectablefactory.java:190)&#xd; 

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

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -