Hello Dear All,
I am trying to post an attachment to a document or upload an excel file by using restful webservices via cURL. However, I could not make it working so far. I believe I am doing something wrong with my xml request which I post. Could you please advise me on the subject?
Here is the command I have sent for uploading excel files, after I logged on successfully to the server:
curl -i -X "POST" -H "accept:application/xml" -H "content-type:multipart/form-data" -H "X-SAP-LogonToken:"%logtok%"" -d "@spreadsheet.xml" http://pvs9060:6405/biprws/raylight/v1/spreadsheets
content of the spreadsheet.xml file as follows:
<content name="attachmentInfos" type="application/xml">
<spreadsheet>
<name>Rests</name> // this is the file name
<folderId>38370</folderId> // this is the folder ID in BO server
</spreadsheet>
</content>
<external-content name="attachmentContent" content-type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" filename="C:/.../Rests.xlsx" /external-content>
Same logic applies to attachments as well...
curl -i -X "POST" -H "accept:application/xml" -H "X-SAP-LogonToken:"%logtok%"" -H "content-type:multipart/form-data" -d "@attachment.xml" http://pvs9060:6405/biprws/raylight/v1/documents/38372/attachments
Content of the attachment xml as follows:
<content name="attachmentInfos" type="application/xml">
<attachment>
<name>Attach_text</name>
<mimeType>text/plain</mimeType>
<size>123</size>
</attachment>
</content>
<external-content name="attachmentContent" type="text/plain" filename="C:/../Test.txt"/>
The problem I am facing is with multipart/form-data types. These 2 post commands should in that format, but I just couldnt manage how to put in a right format to send the request.
Here are what I tried:
- Replacing -d with -f
-Sending xml part with -d @xml and the file with -f upload=@filename in the same command
-Changed the direction of the slashes in the xml file for the path of the upload file ( slash (/) and backslash(\) )
What am I missing here? Could you please help on the subject?
Best Regards,
Kartal