rest - TCL HTTP set up headers to send post request -
I'm totally new to TCL.
I am trying to send a post request to a server. The headers I'm trying to send:
"POST test HTTP / 1.1" "Content-Type: Application / x-www-form-urlencoded" "Keep-alive: True "" Authorization: Basic khjkjkhkhkfzxc "" Customer: Amin "" Content-Length: 10 "" ggggsis "
My code is:
set bs" Set the original khjkjkhkhkfzxc "Set HD [List Authority $ BS] set vaccine [http: geturl $ url -headers $ hd] set [http: data $ tk] http: cleanup $ tk return $ tk
Why does not this work? Where's my fault And how to fix it?
Your help is greatly appreciated. Thanks
Edit : I created a small server socket to display my request and here is my new code for posting:
< Code> Set BS "Basic gfhfghfdhgf" set HD [List Authority $ bs] Token Set [http: geturl $ url -headers $ hd -query] [http :: formatQuery blabla blablo] Type :: "text / xml"] Set up postStat [Http: status $ token] set postResp [http: Data $ Tokens] puts $ postResp "OK" $ postStat puts
displayed here
The problem is that the program is sent after, but does not move out of token set [ Http: geturl $ url -headers $ hd -query [:: http: formatQuery blabla blablo] -type "text / xml"],
AND never sent httpget query Going ("done" is never being printed and does not print the contents of the query on the server side)
If I do things badly, Do expertise so forgiving him.
Thanks
As a dictionary, you want to send instead of creating headers It's easy:
dict set HD authorization "Original [Binary Encoder base64 $ {user}: $ {pass}]" Direct Set HDR Client Amine
Other headers that you talk about are either true (content type) or are left to handle the http library properly.
Once you find the header and the data , then you POST
like this:
set token [Http: geturl $ theurl -headers $ hdr -query $ body] Set Response Time [http: Data $ Tokens] # Use the header here ... http: cleanup $ token #Token is no longer valid
< / Pre>Note that you can only reach the results of the query unless the command is called on it. After that, the results have gone (unless you store them in a variable elsewhere.)
You want to make sure that
set body [http: formatQuery fredKey fredValue daveKey daveValue foo bar]$ body
is formatted correctly
Comments
Post a Comment