12-27-2017 7:24 AM
Dear All.
As I make new program interfacing with http API, 500 error code is occurring.
Calling API via IE is just like this
It's working well :
But in abap program, I got 500 error,
Would you please what's problem in my source ??
source code 1)
CALL METHOD cl_http_client=>create_by_destination
EXPORTING
destination = 'MGAGE_BULK'
IMPORTING
client = lo_client
EXCEPTIONS
destination_not_found = 1
internal_error = 2.
request = lo_client->request.
CALL METHOD lo_client->request->set_method(
if_http_request=>co_request_method_post ).
CONCATENATE
'<MESSAGE VER="1.2">'
'<USER USERNAME="*****"' 'PASSWORD="*****" DLR="0"/>'
'<SMS TEXT="This is first sms" ID="1" CUST_MID="customer-reference-uniqueid-20011234567890" MTAG="unique_message_tag_1">'
'<ADDRESS FROM="MGAGE" TO="+918826466" SEQ="1"/>'
'</SMS>'
'<SMS TEXT="This is second sms" ID="2" CUST_MID="customer-reference-uniqueid-20011234567891" MTAG="unique_message_tag_2">'
'<ADDRESS FROM="MGAGE" TO="+91882466" SEQ="1"/>'
'</SMS>'
'</MESSAGE>'
INTO lv_bodystr.
name = 'data'.
value = lv_bodystr.
CALL METHOD request->set_form_field
EXPORTING
name = name
value = value.
CALL METHOD lo_client->send
EXCEPTIONS
http_communication_failure = 1
OTHERS = 4.
IF sy-subrc EQ 0.
lo_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4 ).
lo_client->response->get_status( IMPORTING code = lv_http_code
reason = lv_reason ).
lv_cdata = lo_client->response->get_cdata( ).
12-27-2017 7:36 AM
Could you please format your code with CODE button.
12-27-2017 7:50 AM
first time to register question here.
modify it now 🙂
12-27-2017 10:19 AM
Hi Kyoungmi,
As you are attempting to consume an HTTPS service, you will first need to configure the security certificate in tcode STRUST (under SSL-client Anonymous). You can see and download the certificate by clicking on the lock icon next to the URL in Internet Explorer. Simply download and import it in your SAP system. Assuming that everything else is configured correctly, this should solved the issue.
Additionally, check for a more detailed message in tcode SMICM.
BR,
Tudor
12-28-2017 2:52 AM
Hi, Tudor
We already set up certificate for this URL.
What I want to know is whether calling API via abap is correct or not.
It not, what's problem on it.
Thanks in advance.
BR.KM
12-27-2017 9:43 PM
Isn't the HTTP error code 500 an "application error" (i.e. which occurs in the called system), so don't you get another message in the variable lv_cdata?
As said by Tudor, use SMICM to trace the request sent + errors (eventually increase the trace level too).
Maybe, you should call the following method, because you use special characters < and > which should be passed with values %3C and %3E (AKA "URL encoding"):
request->SET_FORMFIELD_ENCODING( request->CO_FORMFIELD_ENCODING_ENCODED ).
12-28-2017 2:55 AM
Hi, Sandra
As I set Service No = 443 in sm59, 500 error is not occuring, but 400 error in sm59.
It's because there's no any parameter on sm59 connection test, but in abap program as you can see above, i put parameter on it.
Nevertheless I've got 400 error.
so What I want to know is whether calling API via abap is correct or not.
It not, what's problem on it.
Thanks in advance.
BR.KM
12-28-2017 9:16 AM
The code seems correct except what I said. I won't repeat. If it's unclear, please tell us what you don't understand.
PS: 400 means (from Wikipedia + https://tools.ietf.org/html/rfc7231#section-6.5.1 ) : "Bad Request. The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing)."
12-28-2017 3:17 AM
In sm59 test..here's result.
This page can’t be displayed
12-28-2017 9:20 AM
So, in fact your question is all about the configuration of SM59 RFC destination. Unfortunately you don't give any information about your config. You may also get some information in SMICM (Internet Communication Manager) HTTP trace, as we already said.