cancel
Showing results for 
Search instead for 
Did you mean: 

Error while implementing get_entity.

amrit403
Explorer
0 Kudos

I have created an OData service and implemented the get_entityset and get_entity method. The get_entityset is working fine but the get_entity method throws a 404 error. Below is the code for the get_entity method and the DB table has 6 fields as seen in the code. Also, find the error screenshot in gateway client.error.png

I have used this link as a reference.

METHOD headerset_get_entity.

    DATA:  ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
           lv_tor_id  TYPE zpayment_header-tor_id,
           ls_header  TYPE  zpayment_header.
    READ TABLE it_key_tab WITH KEY name = 'TOR_ID' INTO ls_key_tab.
    lv_tor_id = ls_key_tab-value.
    SELECT SINGLE * FROM zpayment_header INTO ls_header WHERE tor_id = lv_tor_id.
    IF sy-subrc = 0.
      er_entity-tor_id    = ls_header-tor_id.
      er_entity-source = ls_header-source.
      er_entity-destination  = ls_header-destination.
      er_entity-dept_date_time     = ls_header-dept_date_time.
      er_entity-amount     = ls_header-amount.
      er_entity-status   = ls_header-status.
    ENDIF.
  ENDMETHOD.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member251534
Participant
0 Kudos

Hello ,

Since select fails and sy-subrc er_entity is blank this error appears . Please comment er_entity code and then try to debug the service

former_member185414
Active Contributor
0 Kudos

Your OData call should be like below

1. Get Entityset: <service path>/<EntitysetName>?<$format=......(additional parameters and filters)

2. Get Entity: <service path>/<EntitysetName>(key1=value1,key2=value2)?<$format=......(additional parameters and filters)

Value for keys need to be encapsulated in single quotes if its a character type.

amrit403
Explorer
0 Kudos

Tried it Ankit. But didn't work.

former_member185414
Active Contributor
0 Kudos

What is the entityset name and paste the URL