Hello,
We have a mobile app that sends form data into an external service via REST-api. Now we want that the user can take a photo and attach it to the request sent to the service.
All other fields are sent fine but we have a problem sending the attachment with the request. We use the FilePlugin to save the file taken by the camera of the mobile device. The uri shows that the file exists in (on android device): "file:///storage/emulated/0/Android/data/com.outsystemsenterprise.ourtenant.ourapp/files/ticketAttachment.png"
Our requestbody text is like this:
"------WebKitFormBoundaryXContent-Disposition: form-data; name=""userid""
"+GetMyDetails2.List.Current.MyDetails.ServiceDeskId+"------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=""categoryId""
9------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=""body""
"+NewTicketBody+"------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=""subject""
"+NewTicketSubject+"------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=""priorityId""
0------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name=""uploadFile""; filename="""+FileUri+"""Content-Type: image/png
------WebKitFormBoundaryX--"
The body above is being converted to binary before sending.
As I mentioned above everything else is sent succesfully to the service but the attachment never finds it's way to the destination and the destination service gives no error. We have tested the request with Postman and it works. We are definitely doing something wrong here but we can't figure out what. It must be connected with the file location of the mobile device.
Hi Jani,
Did you debug the output by checking the output in Service Center (after increasing the debug level)?
Kilian Hekhuis wrote:
Hi Kilian,
Thank you for your answer.
Yes, we set the debugging level to full and it shows us "HTTP/1.1 200 OK" and correct response (the external services object id which means that the object has been created successfully) and no mention about the attachment so the request should not be completely wrong.
Here's the full log:
--------------------------------------------
POST https://xxxxx.com/api/ticket HTTP/1.1User-Agent: OutSystemsPlatformContent-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gWAuthorization: Basic SEFNS1xqaXRiaXRhcGk6SkI9YXBpIWhhbWs=Host: xxxxx.com
Content-Length: 735
<BINARY DATA>
HTTP/1.1 200 OKAccess-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONSAccess-Control-Allow-Headers: accept, authorization, content-typeAccess-Control-Allow-Credentials: trueContent-Length: 4Cache-Control: private, s-maxage=0Content-Type: text/html; charset=utf-8Date: Fri, 13 Apr 2018 09:27:53 GMTSet-Cookie: ASP.NET_SessionId=43tgqketnuxa34f1c2he12k2; path=/; secure; HttpOnlyX-Powered-By: ASP.NET
4336
The last digit above this line is the correct object id that the external service returns.
BR,Jani
I assume the <BINARY DATA> is the base64 encoded document?
The only other thing I could think of is some overly active firewall or anti-virus software just chopping of the attachment.