cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

READ method not executing in RAP Web API V4

DEB1989
Explorer
0 Likes
1,378

Hello Team,

I have created Unmanaged RAP V4 Web API OData service. 

For READ operation I can see all data are coming. But when I am trying to access wrong key field data (which is not available in table) I am getting exception "Resource Not found". So, I have added some meaningful message in READ method. But that message is not coming. I have put debug point in READ method but when I am trying to GET call from GW Client debugger point not triggering. 

What is the issue? Can you please help me?

Even when I am sending correct data from gw client, I am getting correct data without hitting breakpoint in READ method.

So, is READ method not triggering during GET call from OData V4 web api ?

 

Thanks

Accepted Solutions (0)

Answers (5)

Answers (5)

junwu
SAP Champion
SAP Champion

that's normal.

eml read will hit your read method.

odata query is hitting the cds if I am not wrong.

ArunJacob
Active Participant
0 Likes

 Hi DDEBORSHI,

May be the framework is bypassing the READ method. Just can you include use read;  also in behaviour to force trigger read logic?

ArunJacob_0-1743764061172.png

Also please ensure cache cleanups (/IWFND/CACHE_CLEANUP
/IWBEP/CACHE_CLEANUP) and Restart the Service (/IWFND/MAINT_SERVICE) as usual to get the changes reflected.

Thanks,

Arun

 
ArunJacob
Active Participant
0 Likes

Hi,

In the handler class, hope it is explicitly maintained (the read operation), I mean something like below: -

CLASS zcl_my_handler IMPLEMENTATION.

  METHOD read_entity.
    DATA: lt_data TYPE TABLE OF zmy_entity.

    TRY.
        SELECT * FROM zmy_entity
          INTO TABLE lt_data
          WHERE key_field = @Keys-key_field.  " Use your key field

        IF lt_data IS INITIAL.
          RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
            EXPORTING textid = /iwbep/cx_mgw_busi_exception=>business_error
                      message = 'Record not found!'.
        ENDIF.

        result = lt_data.  " Return the result

      CATCH cx_sy_open_sql_db INTO DATA(lx_sql).
        RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception
          EXPORTING message = lx_sql->get_text( ).

    ENDTRY.

  ENDMETHOD.

ENDCLASS.

and once this is there, can be please put a BP in this and see?

Thanks,

Arun

 

DEB1989
Explorer
Hi Arun, I have done this.
MioYasutake
SAP Champion
SAP Champion
0 Likes

@DEB1989 

From my experience, the READ method is called when READ ENTITY EML is executed. For HTTP GET requests, data is read from the underlying CDS view. 

DEB1989
Explorer
0 Likes

Hi Mio,

Thanks for your reply.

I have doubt here, when I am doing POST and DELETE operation from URL then I see CREATE and DELETE methods are triggering. So only for GET it taking from CDS. Is it?

Thanks

ArunJacob
Active Participant
0 Likes

Hi,

OData V4 handles read differently than OData V2.

Have you explicitly implemented readEntity?(custom logic in in Behavior Definition + Behavior Implementation), because In Unmanaged RAP, if you haven’t explicitly implemented readEntity, the framework might bypass your custom logic.

Thanks,

Arun

 

DEB1989
Explorer
0 Likes

Hi Arun,

I have Implemented READ method which is created default.

DDEBORSHI_0-1743749408106.png

 

Thanks