POST /1/2fa HTTP/1.1
Host: https://rest.fortytwo.com
Content-Type: application/json
Authorization: Token 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Cache-Control: no-cache
{
"client_ref" : "refnum_1598195",
"phone_number": "35688000000",
"code_length": 6,
"code_type": "alpha",
"case_sensitive": true,
"callback_url": "http://example.com/callback",
"sender_id" : "FortyTwo2FA"
}
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://rest.fortytwo.com/1/2fa",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n\n \"client_ref\" : \"refnum_1598195\",\n \"phone_number\": \"35688000000\",\n \"code_length\": 6,\n \"code_type\": \"alpha\",\n \"case_sensitive\": true,\n \"callback_url\": \"http://example.com/callback\",\n \"sender_id\" : \"FortyTwo2FA\"\n}\n",
CURLOPT_HTTPHEADER => array(
"authorization: Token 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -H "Cache-Control: no-cache" -d '{
"client_ref" : "refnum_1598195",
"phone_number": "35688000000",
"code_length": 6,
"code_type": "alpha",
"case_sensitive": true,
"callback_url": "http://example.com/callback",
"sender_id" : "FortyTwo2FA"
}
' "https://rest.fortytwo.com/1/2fa"
import requests
url = "https://rest.fortytwo.com/1/2fa"
payload = "{\n\n \"client_ref\" : \"refnum_1598195\",\n \"phone_number\": \"35688000000\",\n \"code_length\": 6,\n \"code_type\": \"alpha\",\n \"case_sensitive\": true,\n \"callback_url\": \"http://example.com/callback\",\n \"sender_id\" : \"FortyTwo2FA\"\n}\n"
headers = {
'content-type': "application/json",
'authorization': "Token 5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
'cache-control': "no-cache",
'postman-token': "2c7623ae-09ff-ea0d-092d-d930319b90ce"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)