The cUrl I have been supplied is this:
Code: Select all
curl -X 'POST' \
'https://xxxx.azurewebsites.net/api/Authenticate/Login' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"email": "user@example.com",
"password": "string"
}'
Code: Select all
https://xxxx.azurewebsites.net/api/Authenticate/Login
Code: Select all
on mouseUp pMouseButton
local tUrl, tPostData, tHeaders, tError
tsNetInit --initialize the tsnet library
put fld "FldEmail" into tEmail
put fld "FldPassword" into tPassword
put fld "FldURL" into tURL
--post json
put quote & "email" & quote & ":" & quote & tEmail & quote into tPostData
put CRLF & quote & "password" & quote & ":" & quote & tPassword & quote after tPostData
put "{" & tPostData & "}" into tPostData
put "Accept:*=Content-Type: application/json" into tHeaders
put tsNetPost("connectionA",tUrl,tHeaders,tPostData,"postResponse") into tError
end mouseUp
on postResponse pID, pStatus, pBytes, pResult
local tError, tData, tResponse
if pResult is not 0 then
-- If pResult is not 0, then a libcurl error occurred, call tsNetRetrError() to get more detail of the error
put tsNetRetrError(pID) into tError
answer "Error:" && tError && "while retrieving data for entry" & pID
else if the first char of pStatus is not 2 then
-- Successful HTTP transactions get a 2xx response code, so error if this is not the case
answer "Received HTTP response code" && pStatus && "while retreiving data for entry" & pID
else
-- Otherwise we have a successful transaction, so retrieve any data that was returned
put tsNetRetrData(pID, tError) into tData
if tError is not empty then
-- This should only happen if the external ran out of memory retrieving the data, or the connection was already closed
answer "Error:" && tError && "while retrieving data for entry" & pID
end if
end if
-- Always close the connection to release any memory allocated to the connection
tsNetCloseConn pID
if tData is not empty then
answer tData
end if
end postResponse
Thanks