Accessing the REST Entities

Procedure

The signature of the method IF_REST_RESOURCE~POST provides access to the multipart REST entity. This interface is also used for non-multipart requests, so the IO_ENTITY object that is passed in is cast to the interface IF_REST_MP_ENTITY (MP = m ulti p art) of the REST library to gain access to the multipart methods of the entity object.

Example:

method if_rest_resource~post.

  data:
        lo_mp_entity_req type ref to if_rest_mp_entity.

  try.
      lo_mp_entity_req ?= io_entity.
  catch cx_sy_move_cast_error.
    mo_response->set_status( cl_rest_status_code=>gc_client_error_bad_request ).
    mo_response->set_reason( if_http_status=>reason_400 ).
    return.
  endtry.
  ...
endmethod.