Skip to Content
0
Former Member
Jan 16, 2012 at 10:28 AM

Request PUT Method REST service

1032 Views

Hi expert,

I try to send a put request to a REST service :

lv_url = 'muurl'.

  • *Create Client

call method cl_http_client=>create_by_url

exporting

url = lv_url

importing

client = http_client.

*

call method http_client->request->set_method('PUT').

CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD

EXPORTING

NAME = 'accept'

VALUE = 'application/xml'.

  • Send

call method http_client->send

exceptions

http_communication_failure = 1

http_invalid_state = 2.

  • Receive

call method http_client->receive

exceptions

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

if sy-subrc ne 0.

http_client->response->get_status(

importing

code = lv_ret_code

reason = lv_err_string

).

message lv_err_string type 'I'.

endif.

  • Now we have the response , parse , display

  • do what you like

ret = http_client->response->get_cdata( ).

  • close

call method http_client->close

exceptions http_invalid_state = 1

others = 2.

The rt contains the value JAXBException occurred : Premature end of file.. Premature end of file..

Does ABAP support the PUT method ?

Thanks in advance