Hi guys,
I'm trying to figure out, how to create an event with attachment.
Creating an event works so far.
(...) HttpPost jamRequest = new HttpPost("/api/v1/OData/Groups('" + groupID + "')/UpcomingEvents"); (...) and in the JSON file: String jsonToSend = ""; jsonToSend += "{"; jsonToSend += "\"Name\": \"" + eventName + "\","; jsonToSend += "\"StartAt\": \"" + startAt + "\","; jsonToSend += "\"EndAt\": \"" + endAt + "\""; jsonToSend += "}"; StringEntity entity = new StringEntity(jsonToSend); jamRequest.setEntity(entity);
But how to get the attachment here?
Then I thought maybee to first create Event, then create a ContentItem and then "link" both.
So next thing I tried out, was how to upload 'ContentItem':
Therefore I uploaded a "test.pdf"-file on the server in Folder "Events":
Upload File works:
(...) HttpPost jamRequest = new HttpPost("/api/v1/OData/ContentItems"); //Setting the request and response formats to json jamRequest.addHeader("Content-Type", "application/pdf"); jamRequest.addHeader("Slug", "test.pdf"); jamRequest.addHeader("Accept", "application/json"); String fileDesc = request.getParameter("slug"); String contentType = "application/pdf"; String file = request.getParameter("file"); String root = getServletContext().getRealPath("/"); File path = new File(root + "/Events"); File filepath = new File(path + "/" + "test.pdf"); FileEntity inputData = new FileEntity(filepath,contentType); jamRequest.setEntity(inputData); (...)
Is it possible to link my ContentItem with a Event.
Or maybee create an Event directly with attachment?
The SAP JAM OData API is not very helpful here and I didn't found any helpful page anywhere. I found "SAP_Jam_OData_HCP" on github which were nice for a good start, but there ar no examples for events :/
Thank you!