Page 1 of 1

Posting a picture with libURLFormData

Posted: Thu Oct 21, 2021 10:05 pm
by simon.schvartzman
Hi guys, 4 days and counting since I started to try to use a cURL method in order to upload a picture to a service provider...

Anyway now I'm at a point that the error message I'm getting seems to tell me something about what I'm doing wrong but I'm stupid enough to not being able to understand it...

this is my code

Code: Select all

-- build the body
put "bbb" into tphoto_id
put "aaa" into tvisit_id
put "ccc" into tscene_id
put "<file>" & "/Users/simonschvartzman/Downloads/Pic1.jpg" into tFile 

-- build the call
get libURLFormData("visit_id", tvisit_id, "scene_id", tscene_id, "photo_id", tphoto_id, "photo_data", tFile)
put it into aux

-- fire the post
post aux to url tURL
put it into tResponse
and the error i'm getting
{"type":"error","message":"1 validation error for Request\nbody -> photo_data\n Expected UploadFile, received: <class 'str'> (type=value_error)","status":422}
Any ideas of what am I doing wrong?

Thanks

Re: Posting a picture with libURLFormData

Posted: Thu Oct 21, 2021 10:37 pm
by matthiasr
Simon,
i am not sure you can use LibURLFormData with files.

Did you try ibURLMultipartFormData instead already? I've always used ibURLMultipartFormData when i uploaded/posted files to a server.

Regards,
Matthias

Re: Posting a picture with libURLFormData

Posted: Fri Oct 22, 2021 2:20 am
by simon.schvartzman
Matthias many, many thanks for your answer. My bad, I should have seen the difference between LibURLFormData and libURLMultipartFormData

I got it working now ...

Do you (or anyone else) by any chance know the equivalent to libURLMultipartFormData in mobile?

The App I'm working on is to be deployed in mobile and according to the dictionary libURLMultipartFormData only works on mac, windows, linux, html5.

Once again many thanks for your input.

Regards

Re: Posting a picture with libURLFormData

Posted: Sun Oct 24, 2021 11:49 pm
by matthiasr
Simon,

i would say, just forget what the dictionary says about the supported platforms. ;)

I just did a test with my iPhone and it worked.
You just have to make sure that in the case that you've set the inclusions in the standalone settings to "Select inclusions for the standalone application" that you then have selected also the Internet library. If you've set the settings to "Search for required inclusions..." then the Internet library is included automatically.

Re: Posting a picture with libURLFormData

Posted: Mon Oct 25, 2021 2:24 am
by simon.schvartzman
Thanks Mathias, as a matter of fact earlier today I reached the same conclusion (it worked ok on both Android and iPhone) and posted about it in another thread

viewtopic.php?f=53&t=34753

I also sent a mail to support noting that maybe the dictionary has to be reviewed.

I'm happy is working even though I wasted two days of work searching for a solution (i even developed my own library before deciding to test the original one on mobile) :shock: :shock: :shock:

Regards