2016 Jul 26 8:16 AM
Hi Experts,
I am able to do GET/POST methods with CL_HTTP_CLIENT,but while i am trying to PUT method it's getting error says "Method Not Allowed" HTTP-405.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
* INTO cv_error_msg.
* cv_error_occurred = 'X'.
* RETURN.
ENDIF.
lo_client->authenticate(
username = 'xxx'
password = 'xxx'
).
*
CALL METHOD lo_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'PUT'.
"lo_client->request->set_method( 'PUT' ).
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = iv_json_data
IMPORTING
buffer = l_params_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
lo_client->request->set_data( l_params_xstring ).
lo_client->request->set_content_type( 'application/json' ).
CALL METHOD lo_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc = 0.
ENDIF.
CALL METHOD lo_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CALL METHOD lo_client->response->get_status
IMPORTING
code = l_http_status_code
reason = l_status_text.
Let me know what i have missed in the above
Thanks,
Syam
2016 Jul 26 8:39 AM
I guess the error is not from your side, but from the server (PUT not allowed by the server). You should better ask the admin or search internet.
Hi Sandra,
Thanks for quick response.
But ,while testing from the Postman of the URL with PUT method is allowing the server and make the updates the data as a sending through payload.
Thanks,
Syam
2016 Jul 26 8:39 AM
I guess the error is not from your side, but from the server (PUT not allowed by the server). You should better ask the admin or search internet.
2016 Jul 26 9:49 AM
Hi Sandra,
Thanks for quick response.
But ,while testing from the Postman of the URL with PUT method is allowing the server and make the updates the data as a sending through payload.
Thanks,
Syam
2016 Jul 26 9:55 AM
Did you trace and compare the two HTTP messages to identify where they are different? (Fiddler, etc.)
2016 Jul 26 2:42 PM
Good to know the problem is solved. Could you tell us what the problem was, and how you solved it? Thanks!
2016 Jul 26 2:52 PM
Hi Sandra,
Ya sure..
Because I am not passing the Key value to the URL.
Thanks,
Syam
2022 Oct 20 8:37 PM
Hi Syambabu,
Please let me know if how did you fix this
Thanks
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |