How to create defect programmatically
One answer
Take a look at Ralph's blog post on getting started with RTC APIs https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ - It's a great starting point for understanding the APIs and how to use them create things in EWM.
Comments
There are two options.
Option 1 Using the Java API, see link above. Also see https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation
Option 2 Using the OSLC API see https://rsjazz.wordpress.com/2022/02/02/ewm-work-item-oslc-cm-api/