ABAP: POST 方式建立连接

2023-12-13 06:01:46

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

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中的调用,

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

文章来源:https://blog.csdn.net/qq_39128364/article/details/134953253
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。