I'm trying to use the following tcl script to login into betfair non-interactively:-
#!/usr/bin/env tclsh
package require TclCurl
set postData "username=xxxxxxxxx&password=yyyyyyyyy"
set postHeader [list "X-Application: curlCommandLineTest"]
set BFLogin [::curl::transfer -url https://identitysso-cert.betfair.com/api/certlogin \
-headervar loginHeader \
-sslverifypeer 0 \
-sslcert "client-2048.crt" \
-sslkey "client-2048.key" \
-post 1 \
-postfields $postData \
-httpheader $postHeader ]
However, it's not storing the output in BFLogin. Instead when the script finishes it just outputs something like:-
{"sessionToken":"92YN1v2Oz0lVv59nHwCryrfCnzNbInTCsssssssssssssssssss","loginStatus":"SUCCESS"}
Which is fine but it's not storing it in the variable BFLogin above. What am I doing wrong please?
From what I gathered from this manual and the wiki, it seems like you can use the option -bodyvar
to tell curl where to store the body response (the call response and the body response are separate). I cannot test the code, but it should probably work like that:
#!/usr/bin/env tclsh
package require TclCurl
set postData "username=xxxxxxxxx&password=yyyyyyyyy"
set postHeader [list "X-Application: curlCommandLineTest"]
set responseBody ""
set BFLogin [::curl::transfer -url https://identitysso-cert.betfair.com/api/certlogin \
-bodyvar responseBody \
-sslverifypeer 0 \
-sslcert "client-2048.crt" \
-sslkey "client-2048.key" \
-post 1 \
-postfields $postData \
-httpheader $postHeader ]
I also removed the headervar option you had, since it doesn't look like you were using it