I have an interface requiring oauth authentication. I call the authentication service to identify myself and then am handed back a token, which I can then use in a following step to call an update service.
I ran the following from the command line on my server to ensure curl is supported:
curl –location –request POST ‘https://testserver/api/public/tokenauth/authenticate’ –header ‘Content-Type: application/json’ –data-raw ‘{“tenancyName”:”tenant”,”userNameOrEmailAddress”:”tenant@tenant.uk”,”password”:”PASSW0RD123″}’
The result message for this call is returned, and the message includes the token as expected.
I’m trying to do something similar with tclcurl in a tcl script.
package require TclCurl
echo “start oauth”
echo “about to call authentication service”
set url “https://stg-mdc-uks-public-api.azurewebsites.net/api/public/tokenauth/authenticate”
set jsonBody “{\”tenancyName\”:\”tenant\”,\”userNameOrEmailAddress\”:\”tenanct@tenant.uk\”,\”password\”:\”PASSWORD\”}”
set JSONResponse “”
echo “url is $url”
set typ “application/json”
set ch [curl::init]
$ch configure -post 1
$ch configure -postfields $jsonBody
$ch configure -url $url
$ch configure -httpheader [ list “Content-Type: $typ”]
$ch configure -bodyvar JSONResponse
catch { $ch perform } returnCode
echo “returncode is $returnCode”
echo “message is $JSONResponse”
When I run this from a thread and check the output, there are no errors. The value for returnCode is 1, but JSONResponse appears to be empty.
Assuming that I am correct in thinking that the authentication service has been successfully called, how can I get the response message as it doesn’t seem to be returned, or maybe I’m looking for it in the wrong place.