I have a requirement to expose OData for an entity and consume data from on premise system. The input can be json/xml/csv. On getting the data a new record will be created. Can someone please help here. Also could you please explain the process of creating odata and where do I need to write my code ie in the AX, on prem or middleware?
Public data entities are automatically available through OData web service. You can learn more from documentation and find example of OData service consumption on GitHub. Note that you don't have to write the client code if you use Logic Apps (or Power Automate), which already has a connector to this service.
If you get data for more records at once, consider if you shouldn't rather import them in one go through data management APIs.
Hopefully it's all supported on-premises as well (I'm not sure because I don't have any on-premises deployment).