ABAP: POST 方式建立连接

1、采用APIpost 设置截图如下:

ABAP: POST 方式建立连接_第1张图片

ABAP建立调用设置

 DATA: lr_http_client TYPE REF TO if_http_client.
 DATA: l_url TYPE STRING.

"建立服务 http客户端
CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url                = l_url "连接的地址
        IMPORTING
          client             = lr_http_client
        EXCEPTIONS
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          OTHERS             = 4.

"设置请求类型:post方式
 lr_http_client->propertytype_logon_popup = lr_http_client->co_enabled .
      CALL METHOD lr_http_client->request->set_header_field
        EXPORTING
          name  = '~request_method'
          value = 'POST'.
      "设置post 的header
      CALL METHOD lr_http_client->request->set_header_field
        EXPORTING
          name  = 'key'
          value = 'ertyuiokjh'. " header 中的key值
      CALL METHOD lr_http_client->request->set_header_field
        EXPORTING
          name  = 'secret'
          value = 'kmnddsfghjkopoiuytrdRTYUIKJiuytd'. " header 中的secret值

2、如果有认证,如下图所示

ABAP: POST 方式建立连接_第2张图片

ABAP中的调用,

    CALL METHOD lr_http_client->authenticate(
      EXPORTING
        username = "user"     "账号
        password = "password" "密码
    ).

你可能感兴趣的:(ABAP,SAP)