Http Example 3

execute ibeblock
as
begin
 /* Data for authentication */
 dvClientId = '4212a0d3-822b-466b-b0ca-b563e671195e';
 dvSecret   = '99ec55d8-cbb3-490e-aaac-f6d40fbbdb3e';

 /* Call the utility to get an EP certificate and keep it in the file */
 ibec_Exec('C:\GbSklad\IBExpert\gbsign.exe thumbprint -index 1 -o "C:\Temp\thumbprint.txt" -provider 75',null,null);

 /* Load from a file */
 dvUserId = ibec_LoadFromFile('C:\Temp\thumbprint.txt');

 /* create JSON */
 dvJSON   = ibec_AnsiStringToUTF8('"{"client_id":"'||dvClientId||'","client_secret":"'||dvSecret||'","user_id":"'||dvUserId||'","auth_type":"SIGNED_CODE"}"');

 /* create header */
 dvHeader = 'Authorization: token '||ibec_CRLF()||'Content-Type: application/json';
 dvURL    = 'URL=https://api.mdlp.crpt.ru/api/v1/auth';

 dvSESS   = ibec_http_OpenSession(:dvURL);
 ibec_http_SetHeader(:dvSESS,:dvHeader);
 ibec_http_Post(:dvSESS,:dvJSON);
 dvScode = ibec_http_StatusCode(:dvSESS);
 dvSdesc = ibec_http_Data(:dvSESS);
 ibec_ShowMessage('Response: '||:dvScode||'  '||ibec_UTF8ToAnsiString(:dvSdesc));
 ibec_http_CloseSession(:dvSESS);
end