Welcome! Log In Create A New Profile

Advanced

WEBSERVICE REST - Send Image

Posted by IsmirB 
WEBSERVICE REST - Send Image
March 27, 2020 02:17AM
Hi to all. I try to send image with other data from android application to webservice.
I am create REST WebService and create function to receive and write data into database.
My android form look like this:


After click on "Confirm-Save", I start this code:

sRecordContentInJSON is ANSI string
sAnimalPhoto is ANSI string = Encrypt (IMG_Photo, "", cryptNone, encodeBASE64)
vPassage is Variant
vPassage.AnimalID = COMBO_Animal..StoredValue
vPassage.ClientID = COMBO_Client..StoredValue
vPassage.DatePassage = EDT_Visit_Date
vPassage.TimePassage = EDT_Visit_Time
vPassage.VisitorID = gnUserID
vPassage.VisitReport = EDT_Visit_Report
//vPassage.Photo = bufAnimalPhoto
vPassage.Photo = sAnimalPhoto
sRecordContentInJSON = VariantToJSON (vPassage)
maReq is httpRequest
maRep is httpResponse
maReq.URL = gsIPAdresa + "PassageAdd"
maReq..ContentType = "application / json"
maReq.Content = sRecordContentInJSON
maReq..Method = httpPost
myRep = HTTPSend (myReq)
IF ErrorOccurred THEN
Error (ErrorInfo (errFullDetails))
ELSE

IF myDir.DescriptionStatusCode = "OK" THEN
ToastDisplay ("Passage is added with success", toastShort, vaMiddle, haCenter)
ELSE
ToastDisplay (myRep.DescriptionStatusCode + "Problem. Something is wrong", toastShort, vaMiddle, haCenter)
END
END

On REST service my procedure do this:

PROCEDURE AddPAssage ()
sRecordContentInJSON is ANSI string = WebserviceParameter (paramBuffer)
vRec is Variant = JSONToVariant (sRecordContentInJSON)
HReset (Passage)
Passage.AnimalID = vRec.ClientID
Passage.ClientID = vRec.ClientID
Passage.DatePassage = vRec.DatePassage
Passage.TimePassage = vRec.TimePassage
Passage.VisitorID = vRec.VisitorID
Passage.VisitReport = vRec.VisitReport
Passage.Photo = Decrypt (vRec.Photo, "", cryptNone, encodeBASE64)
HAdd (Passage)
RESULT "OK"

Everything is fine except I can not send image. I get empty field "Photo".
Please, can you help me to complete this code so I can send images over webservice.
pao
Re: WEBSERVICE REST - Send Image
March 27, 2020 10:41AM
Try using ENCODE/DECODE instead of the crypt/decrypt and use encodeBASE64URL instead of the encodeBASE64

Regards

Paulo Oliveira
Re: WEBSERVICE REST - Send Image
March 27, 2020 11:10AM
Paulo

Thank You so much, So Much. I spend two days with this and spin in the circle. Don't know about Encode/Decode, because all helps write about crypt/decrypt.

Thank you mate. Have a nice day. I will have it now. smiling smiley

Also, to all members, these days I wish you health and peace in family. winking smiley
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: