@@ -74,15 +74,28 @@ private Response executeWithRetry(Request request) throws IOException {
7474
7575 public String createEntityDraft (
7676 String appUrl , String entityName , String entityName2 , String srvpath ) {
77+ return createEntityDraft (appUrl , entityName , entityName2 , srvpath , null );
78+ }
79+
80+ public String createEntityDraft (
81+ String appUrl , String entityName , String entityName2 , String srvpath , String bookID ) {
7782 MediaType mediaType = MediaType .parse ("application/json" );
7883
7984 // Creating the Entity (draft)
80- RequestBody body =
81- RequestBody .create (
82- mediaType ,
83- "{\n \" title\" : \" IntegrationTestEntity\" ,\n \" "
84- + entityName2
85- + "\" : {\n \" ID\" : \" 41cf82fb-94bf-4d62-9e45-fa25f959b5b0\" ,\n \" name\" : \" Akshat\" \n }\n }" );
85+ String jsonBody ;
86+ if (bookID != null && !bookID .isEmpty ()) {
87+ // Creating a Chapter within a Book
88+ jsonBody =
89+ "{\n \" title\" : \" IntegrationTestEntity\" ,\n \" book_ID\" : \" " + bookID + "\" \n }" ;
90+ } else {
91+ // Creating a Book or other entity
92+ jsonBody =
93+ "{\n \" title\" : \" IntegrationTestEntity\" ,\n \" "
94+ + entityName2
95+ + "\" : {\n \" ID\" : \" 41cf82fb-94bf-4d62-9e45-fa25f959b5b0\" ,\n \" name\" : \" Akshat\" \n }\n }" ;
96+ }
97+
98+ RequestBody body = RequestBody .create (mediaType , jsonBody );
8699
87100 Request request =
88101 new Request .Builder ()
@@ -842,7 +855,9 @@ public String openAttachment(
842855 + appUrl
843856 + "/odata/v4/"
844857 + serviceName
845- + "/Books(ID="
858+ + "/"
859+ + entityName
860+ + "(ID="
846861 + entityID
847862 + ",IsActiveEntity=true)"
848863 + "/"
0 commit comments