Hello,
I am trying to use extension HttpClient to post a file. I always have an errormessage from httpClient : no value for filetopost whatever I put in value for filetopost
Here are the blocks of my app.
Does anyone have an idea about the reason for this error ?
TIMAI2
July 10, 2025, 1:25pm
2
FilePicker returns a contenturi and not a filepath ? Does httpclient extension handle contenturis ?
Don't know. It's the first time I use this extension. I will look at that.
thanks for this idea.
I have tested with fullpath and always the same error. no value for filetopost
I have added a test before posting to check that file exists and It give me the following response:
File: file:///storage/emulated/0/Documents/participants.csv exits.
So I dont know what is expected in filetopost variable
TIMAI2
July 10, 2025, 3:10pm
5
Try removing the file://
prefix
Still the same error after removing file://
Taifun
July 10, 2025, 3:36pm
7
My guess is, your app does not own that file? Where does it cone from?
From an Android point of view there are an → Internal Storage and an → External Storage .
1. Internal Storage
The Internal Storage can only be accessed with a rooted device.
1.1 The app package is saved in
/data/data/<packageName>/
In order to be able to debug your app, AI2 saves the assets for → Companion on devices with
Android ≥ 10 (API ≥ 29):
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/
Android < 10 :
/storage/emulated/0/Android/data/edu.mit.a…
Try to use the filepicker and convert the uri to the path to the file for the httpclient extension
Taifun
It doesn't change anything. same error ??
What's wrong ?.
I don't know if it can help do debug, but when I try to check that the file exits afeter picking it, i get a runtime error message
here are my blocks with check tests
TIMAI2
July 10, 2025, 5:01pm
10
You are not converting the contenturi
For ease, use this extension
I have put a copy of the file in the directory of aicompanion3 and when I make do it on the variable , I see that the path is correct. So I really don't know why it doesn't work.
TIMAI2
July 10, 2025, 5:22pm
12
Again remove the file://
prefix
Also, are you sure you do not need any headers or fields ?
Same error No value for filetopost
Taifun
July 10, 2025, 7:18pm
14
As already mentioned earlier
use the filepicker
convert the content uri into a path to the file, how to do it use
use that path to send it using the httpclient extension
as test to find out if you are able to access the file after step 1 and 2 use the file component to read it
show us all relevant blocks for 1, 2 and 3
and don't hesitate do use Do it to debug your blocks
Taifun
Ok I will try that later since I have no more time available now (9pm in France). Thanks a lot for your help
TIMAI2
July 10, 2025, 9:55pm
16
Have you tested your file upload method with either an html form or curl command (Postman) ?
Yes the file has been uploaded without problem.
Here are the results of my test. Alaways No value for filetopost. Moreover when I use the file component to read it I have Error 2101
As you can see, the file exists on my phone in Documents directory
TIMAI2
July 11, 2025, 7:57am
20
Your File Read from won't work unless you set the correct filescope.
Show the method and syntax for your successful upload.
Provide a link for the API requirements of the site you are uploading to.
Again I ask that you are certain you do not need any headers or fields in your URL?