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: 

Odata to OPENAPI (EDMX File) for Post Method of Custom Odata

RamaniNagarajan
Explorer
0 Kudos
1,934
  • SAP Managed Tags:

Dear All,

We have documentations on getting the OpenAPI. And is working fine only for the Custom Odata with GET Method.

Whereas, am unable to convert POST Method from the same Custom Odata to OpenAPI.

Here is the Odata Screen from Gateway Client for which I would like to get OpenAPI. Please help me.

Thanks and regards,

Ramani

1 ACCEPTED SOLUTION

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,743
  • SAP Managed Tags:

Hi Ramani,

That's the correct URL to get $metadata.

Looking at the metadata.xml and assuming it is what the $metadata request returns, I would have expected the POST request to fail because the fiPostingHeaderSet does not allow creating new entities.

Which means the service implementation and its $metadata are out of sync.

If this service was defined with transaction SEGW, then maybe the service developer forgot to tick the box for "creatable: true" on fiPostingHeaderSet.

You could manually tweak the metadata.xml file accordingly and run the OpenAPI converter to check whether it produces what you expect. Long-term you should contact the service developer to get $metadata back in sync with the implementation.

6 REPLIES 6

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,743
  • SAP Managed Tags:

Guessing from the URL pattern I assume you are using OData V2, flPostingHeaderSet is an entity set, and you are trying to create a new entity in this entity set via a POST request.

This kind of request is supported by this OData-to-OpenAPI converter, see this example:

OData entity set: https://github.com/oasis-tcs/odata-openapi/blob/cdc96556b4111dfca658ac7b3678fdf8a5a81492/examples/od...

OpenAPI operation: https://github.com/oasis-tcs/odata-openapi/blob/a9ebd6a9d021bd670546d06d393dbc5bd942ee0a/examples/od...

0 Kudos
1,743
  • SAP Managed Tags:
fi-metadata.xml

Thanks Ralf Handl for your quick reply!

When I ran it with my metadata.xml, it created a json file next to it. But I unable to see the Entitysets with Post Method in it, still. As suggested, I did the odata-openapi3 MyMetadata.xml also.

I am expecting an entry in the JSON file with POST method on the entity FiHeaderToFiResult. But not found. Is there any way to achieve it please.

*Note: I have attached herewith the Metadata file

Thanks!

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,743
  • SAP Managed Tags:

Hi Ramani,

The metadata.xml looks incomplete to me:

  • It defines an Association FiHeaderToFiResult
  • It does not define a NavigationProperty on FiHeader using this association

As a consequence there is no OpenAPI path where this POST method could be attached to.

Your screenshot above shows a POST request to fiPostingHeaderSet, but your metadata.xml says this is not allowed, sap:creatable is false:

<EntitySet Name="fiPostingHeaderSet" EntityType="ZFI_FS00_POSTING_SRV.fiPostingHeader" sap:creatable="false"

The OpenAPI file can only reflect what your metadata.xml allows.

0 Kudos
1,743
  • SAP Managed Tags:

Hi Ralf Handl,
It is appreciated if you could tell me how to get the Metadata information with these information fully.

Here is the complete screenshot after the execution of the Post Method:

**This is what is execute is: /sap/opu/odata/sap/ZFI_FS00_POSTING_SRV/$metadata


Thanks, Ramani

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,744
  • SAP Managed Tags:

Hi Ramani,

That's the correct URL to get $metadata.

Looking at the metadata.xml and assuming it is what the $metadata request returns, I would have expected the POST request to fail because the fiPostingHeaderSet does not allow creating new entities.

Which means the service implementation and its $metadata are out of sync.

If this service was defined with transaction SEGW, then maybe the service developer forgot to tick the box for "creatable: true" on fiPostingHeaderSet.

You could manually tweak the metadata.xml file accordingly and run the OpenAPI converter to check whether it produces what you expect. Long-term you should contact the service developer to get $metadata back in sync with the implementation.

0 Kudos
1,743
  • SAP Managed Tags:

It worked now.

Thanks Ralf Handl !