Estoy tratando de consumir un servicio REST externo. Ejemplo:
DATA : lo_client TYPE REF TO if_http_client.
cl_http_client=>create_by_url(
EXPORTING
url = 'http://my_url'
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
DATA(rest_client) = NEW CL_REST_HTTP_CLIENT( lo_client ).
rest_client->GET( ).
GET, POST, PUT y DELETE están bien ya que se implementan en la clase CL_REST_HTTP_CLIENT
.
¿Alguien encontró una solución para usar el método PATCH o cómo podría consumirlo de otra manera?
PD: la constante para PATCH existe (if_rest_message=>gc_method_patch
), pero como dije, no está implementada (send_receive).
Gracias.
2 respuestas
Puede usar CL_HTTP_CLIENT para establecer el método libremente, CL_REST_HTTP_CLIENT también está usando esta clase bajo el capó.
DATA : lo_client TYPE REF TO if_http_client.
cl_http_client=>create_by_url(
EXPORTING
url = 'http://my_url'
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
lo_client->request->set_method( 'PATCH' ).
lo_client->request->set_content_type( 'application/json' ).
lo_client->send( ).
lo_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ).
No es compatible de hecho. Una forma rápida y sucia de hacerlo funcionar es copiar la clase y agregar el siguiente método:
method PATCH.
send_receive( iv_http_method = if_rest_message=>gc_method_patch io_entity = io_entity ).
endmethod.
Nuevas preguntas
rest
REST (Representational State Transfer) es un estilo de arquitectura de software para sistemas hipermedia distribuidos como la World Wide Web. Ha aumentado su popularidad en relación con las arquitecturas RPC como SOAP debido al desacoplamiento intrínseco del cliente del servidor que proviene de tener una interfaz uniforme entre sistemas heterogéneos.