Skip to Content
0

Error while calling REST API URL from SAP to COUPA system

Oct 21, 2016 at 05:55 PM

61

avatar image

Hi,

Can you please let me know how to call REST API URL using PUT method from SAP to COUPA system. find my below code. Please suggest.

DATA http_client TYPE REF TO if_http_client.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = 'https://hostxxxxxx/api/purchase_orders/1132'
IMPORTING
client = http_client.

*http_client->propertytype_logon_popup = http_client->co_disabled.
DATA l_username TYPE string.
DATA l_password TYPE string.
l_username = 'uid'.
l_password = 'pwd'. "Password
CALL METHOD http_client->authenticate
EXPORTING
username = l_username
password = l_password.
CALL METHOD http_client->request->set_method('PUT').
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'X-API-KEY'
value = '4f236bfebcfcd24a6f'.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = 'Accept'
value = 'application/xml'.


CALL METHOD http_client->request->set_content_type
EXPORTING
content_type = 'applicatioon/xml'.

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.

CALL METHOD http_client->response->get_status
IMPORTING
code = gv_http_status_code
reason = gv_status_text.

WRITE: / 'HTTP_STATUS_CODE = ',
gv_http_status_code,
/ 'STATUS_TEXT = ',
gv_status_text .

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers