cloud-sdk-js icon indicating copy to clipboard operation
cloud-sdk-js copied to clipboard

Generic OData Client

Open yurecz opened this issue 2 years ago • 5 comments

I am trying to call the instant action in the OData V4 service, which is not currently supported by the Generated OData client. For that, I am looking for a similar Generic OData Client for JAVA https://sap.github.io/cloud-sdk/docs/java/features/odata/generic-untyped-odata-client but cannot find it. Is it something that does not exist in the JavaScript version of the SDK?

yurecz avatar Jun 22 '22 16:06 yurecz

Hi @yurecz,

thank you for reaching out to us. Unfortunately we do not have a generic OData client in the JS version of the SDK, yet. It is on our agenda. We have a http client which would handle the destination stuff for you:

https://sap.github.io/cloud-sdk/docs/js/features/connectivity/generic-http-client

However, you would need to build the request URL and payload manually. If this is enough for you just comment and close the issue. If you need that functionality feel free to close or change this issue to a feature request where I see two options:

  • Generic OData client which would work as a work around for all OData parts we have not implemented
  • Ask to include the instant action for OData V4 -> Here it would be great if you could add the service in question so that we have directly a test case.

Best Frank

FrankEssenberger avatar Jun 23 '22 08:06 FrankEssenberger

Hello Fank,

I would like to change the question to the feature request to enable the instance actions in the OData V4 request(with input parameters). Could you please change the type of the issue as I do not know how to do it?

Meanwhile, I would like to build the workaround using the https://sap.github.io/cloud-sdk/docs/js/features/connectivity/generic-http-client. Could you please provide the example how to call the instance action using this client as the documentation in the wiki is not complete and has the link https://sap.github.io/cloud-sdk/api/2.5.0/interfaces/sap_cloud_sdk_http_client#HttpRequestConfig which is not working.

The test can be done for the publicly available API: https://api.sap.com/api/OP_LASTMILEVISITLIST_0001/overview which has not been updated to include the newly added actions but it will be done next week.

Best regards, Yuri

yurecz avatar Jun 23 '22 12:06 yurecz

Ok once the service is updated and we start working on it, I will most likely ask back about which part of the actions is missing if this is not clear. Regarding the work around, how did you get the documentation link containing the interfaces in the path? This is not working for me. If I follow the links from the main page I end up with this link:

https://sap.github.io/cloud-sdk/api/2.5.0/modules/sap_cloud_sdk_http_client#executeHttpRequest

A example would look like:

      executeHttpRequest(
        { destinationName: 'yourDestinationName', jwt: 'yourJwtIfNeededInAuthFlow' },
        {
          url: 'http://theUrl.com/action/foo/bar',
          method: 'POST',
          params: { key1: 'value2', key2: 'value2' },
          data: { data1: 'value1', data2: 'value2' }
        }
      );

The params will be added as URL query parameters. If you need something like /foo/bar(a=123,b=456) you need to put it in the url. I hope you can replace the values of your use case with the ones in the example.

Best Frank

FrankEssenberger avatar Jun 23 '22 13:06 FrankEssenberger

Hey @yurecz,

we will improve the documentation on the generic HTTP client soon.

Can you please specify the feature you are requesting more exactly? I understand the feature you are looking is also referred to as "bound actions", is that correct? It would be very helpful if you could point me to a service, that includes this OData feature and describe how you would like an API to look like. I checked the Visit List service you shared, but as of today it still does not include any actions.

Thank you in advance.

marikaner avatar Jul 18 '22 10:07 marikaner

Hello @marikaner ,

Yes, it would be great if the generator could be extended to cover the OData V4 bounded actions proxies generation. They should support input parameters.

The service on the API Hub is not yet updated and I attached the EDMX directly to the post: LMDVisitListAPI.zip Look to the action CreateLoadRequest.

Regarding how it should be accessed in the javascript: I have no specific preferences. The action is bounded which means it is executed on the specific instance of the Entity. So, for example, it could be something like: Entity.getByKey('UUID').actionName({paramaters}).execute(). Or you could do it in the same manner as it is done in the OData v2 Proxies, just: actionName({key: UUID, paramaters}).execute()

Best regards, Yuri

yurecz avatar Jul 28 '22 21:07 yurecz

Hi @yurecz

support for OData v4 Bound Functions and Actions is implemented in version 2.11.0 of the sdk. See the updated docs section for info on how to use them.

Feel free to share feedback on how it works for you.

Best, Florian

fwilhe avatar Nov 21 '22 09:11 fwilhe

Unfortunately, we have no plan for the generic odata client due to other priorities.

jjtang1985 avatar Feb 15 '24 09:02 jjtang1985