Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Api is not working

rimpa900
Discoverer
0 Kudos
470

method IF_REST_APPLICATION~GET_ROOT_HANDLER.

DATA lo_router TYPE REF TO cl_rest_router.
CREATE OBJECT lo_router.

lo_router->ATTACH(
EXPORTING
IV_TEMPLATE = '/test' " Unified Name for Resources
IV_HANDLER_CLASS = 'ZCL_GET' " Object Type Name


* IT_PARAMETER = " Resource contructor parameters
).



RO_ROOT_HANDLER = lo_router.



endmethod.

This i have set in handler class.

method IF_REST_RESOURCE~GET.
*CALL METHOD SUPER->IF_REST_RESOURCE~GET
* .

data : lv_string1 type vbeln, "string,
lv_string2 type string,
gs_complaint type ZREST_COMPLAINT.


* lv_string1 = mo_request->get_uri( ).

lv_string1 = mo_request->GET_URI_QUERY_PARAMETER( iv_name = 'ID' ).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lv_string1
IMPORTING
OUTPUT = lv_string1.



select SINGLE * from zrest_complaint into CORRESPONDING FIELDS OF GS_COMPLAINT
WHERE id = lv_string1.


/UI2/CL_JSON=>SERIALIZE(
EXPORTING
DATA = gs_complaint " Data to serialize
* COMPRESS = ABAP_FALSE " Skip empty elements
* NAME = " Object name
* PRETTY_NAME = " Pretty Print property names
* TYPE_DESCR = " Data descriptor
RECEIVING
R_JSON = lv_string2 " JSON string
).


MO_RESPONSE->CREATE_ENTITY( )->SET_STRING_DATA( iv_data = lv_string2 ).


MO_RESPONSE->SET_HEADER_FIELD(
EXPORTING
IV_NAME = 'Content-Type' " Header Name
IV_VALUE = 'application/json' " Header Value

).

endmethod.

and this is the program in zcl_get.

Now after creating API when I am entering that to browser

This site can’t be reached

Check if there is a typo in hanaserver.abc.com.

  • If spelling is correct, try running Windows Network Diagnostics.

DNS_PROBE_FINISHED_NXDOMAIN

this error is showing , why is that.

1 REPLY 1

Sandra_Rossi
Active Contributor
400

Why? Because the SAP server can't be reached. It's NOT related to your ABAP code.

Search information about SICF.