yanweiyuan3
2023-10-26 a89f9faebe6e90c5cf1faeb1d551825e0cb2a06d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Quintiq file version 2.0
#parent: #root
Method ApiResponesCheck (
  String address,
  String url,
  Number port,
  String postrequestbody
) as owning JSON
{
  Description: 'Check if the https link is working'
  TextBody:
  [*
    // Administrator Aug-18-2023 (created)
    
    // for HTTPS requests:
    i := HTTPInterface::Create( address, port);
    //i := HTTPInterface::Create( address ,443);
    info( address, url, port, postrequestbody );
    
    i.URL(url);
    //i.SSL(false);
    i.SSL(true);
    i.SSLKeystore('MyKeystore'); // created in the Config Utility
    
    i.PostMethod(true); //it's a POST method
    
    i.Call(postrequestbody); // Call's argument is for POST method's content.
    htmlresult := i.Result();
    
    htmlresponse := JSON::Parse( htmlresult );
    
    code := htmlresponse.Get( "resultCode" ).GetString();
    message := htmlresponse.Get( "resultMsg" );
    data := htmlresponse.Get( "responseData" );
    datalist := data.Get( "dataList" );
    
    if( code = "1" )
    {
      info( "Data have been written into table" );
      }
    else
    {
      messagestring := " ";
      if ( message.IsNull() )
      {
        messagestring := "No message returns!";
        }
      else
      {
        messagestring := message.GetString();
        }
      info( "Error! error code: " + code + ", error message: " + messagestring );
      }
    
    return &datalist;
  *]
}