Posting a picture with libURLFormData

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Posting a picture with libURLFormData

Post by simon.schvartzman » Thu Oct 21, 2021 10:05 pm

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
Simon
________________________________________
To ";" or not to ";" that is the question

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Posting a picture with libURLFormData

Post by matthiasr » Thu Oct 21, 2021 10:37 pm

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

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Posting a picture with libURLFormData

Post by simon.schvartzman » Fri Oct 22, 2021 2:20 am

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
Simon
________________________________________
To ";" or not to ";" that is the question

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: Posting a picture with libURLFormData

Post by matthiasr » Sun Oct 24, 2021 11:49 pm

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.

simon.schvartzman
Posts: 638
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Posting a picture with libURLFormData

Post by simon.schvartzman » Mon Oct 25, 2021 2:24 am

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
Simon
________________________________________
To ";" or not to ";" that is the question

Post Reply

Return to “Internet”