I am trying to upload an Attachment (file image in jpg format) to a table of SharePoint 2013 throught an Android POST Request.
That table has different columns and one of them is of type Attachment (with the clip icon). However, on the body of the request, I am not being able to upload any data to AttachmentFiles because I don't know how to do it (what is the format of the AttachmentFile I should send?). The code of my request and response is the following:
12-07 12:44:38.450 6133-7240/testapp.com.testapp D/OkHttp: --> POST https://urltest.es/iot/_api/web/lists/GetByTitle('RESULTS_COMMENTS')/items?$orderby=Signed%20asc&$top=100000 http/1.1
12-07 12:44:38.450 6133-7240/testapp.com.testapp D/OkHttp: {"AttachmentFiles":"/storage/emulated/0/Pictures/Attachment20171207_124428-1813646694.jpg","FORMId":3,"COMMENT":"mejdkd","__metadata":{"type":"SP.Data.RESULTS_x005f_COMMENTSListItem"},"USER_LOGIN":"testuser"}
12-07 12:44:38.500 6133-7240/testapp.com.testapp D/OkHttp: <-- 400 Bad Request https://urltest.es/iot/_api/web/lists/GetByTitle('RESULTS_COMMENTS')/items?$orderby=Signed%20asc&$top=100000 (52ms)
12-07 12:44:38.500 6133-7240/testapp.com.testapp D/OkHttp: {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"A 'PrimitiveValue' node with non-null value was found when trying to read the value of a navigation property; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected."}}}
If I remove the "AttachmentFiles" element from the request the petition works correctly and the item is created (201) in the table (but without Attachment).
I know that I am only passing the file path, but I tried to send the file in Base64 or as a byte array and it did not work either. Anyone knows how can the upload be done?
Thanks in advance.