Build a request for a WEB-API to upload photos #need help

Hello friends,
I need your support again

I want to share photos through my chat app. For this I would like to host my photos sleber and use Picapport (PicApport | The self-hosted private photo server with photo gallery and photo management).

Picapport has a web API. Unfortunately, I don’t have a lot of experience with web APIs, even if I’ve read a lot here.

I use the web component. But I haven’t quite understood how to put the requests together :frowning:

After all, I’ve already managed to establish a connection to the server and read out the APISID (= apiKey?) * Proud * :slight_smile:

I have the following questions:

  1. How do I have to build the request to upload a photo using the APISID? #upload
  2. How can I then save the “path” to this photo in the CLoudDB?
  3. how do I have to build the request to download the photo again? #getphoto
  4. how can I secure the connection? #authorizeWebApiSession
    I tried this:

Here is the test overview. What does the API expect - or is it built up? Does that help?

the JSON result is the result of the manual photo upload. How can I draw conclusions from this for the structure of the blocks?

I thank you already now

Dear Rogerio

what did you want to tell me? :slight_smile: I know that you have a lot of experience here :heart:

I can’t go on alone. :tired_face:

Here is an example of how the upload function is structured:

https://wiki.picapport.de/display/PICE/upload

How do I translate this structure into blocks?
I tried the following:

What do i have to change?
Is it better to use Post File or Post text?

First, read the API documentation carefully
Second, do each step required by the API documentation
Is there an API tester on the API website?
Is it working?
After this:
Third, research the topics on web Component + API
There are many, and each with a solution.
Test them out.

1 Like

I have read the web API doko.
There is also an API test page (see Screen.ShoT above) here is the link.
https://en.onlinedemo.picapport.de/picapport-webapitest.html

I can upload and download images via the test page!

As shown, I also guess what the body and what the header is.
I just don’t understand (I guess I’m too stupid) how I can put this into blocks. I’ve read a lot (also with App Inventor) and tried a lot -> see above.

What works well:

With createWebApiSession I get the APISID (session ID) -> the connection to the server works!

According to the API test page, I need the APISID for the upload.
Then I have to set: content-type multipart / form-data.

How do I build the header with APISID?
And how about the body?
Do I have to perform authorizeWebApiSession first?

should it work like that? - but does not work :frowning:
Is there something wrong in the structure or is the authorizeWebApiSession method missing here?

First : web.post.text

Should the header have APISID?

Thank you for your feedback signal

As I said, I read a lot and got very confused as a result :slight_smile:

First tried web.post.text, but then switched to Post.File because of this “Upload to Dropbox” lesson.
https://puravidaapps.com/dropbox.php
There was the authorization with a token in the header.

Or do you think I should add this to the url sooner?

Sometimes curls become quite difficult to implement.
But don’t worry if that api supports/provides Form submission then you can use a webviewer too.

1 Like

Return Code 500 :frowning:

The download URL looks like this, that’s why I tried this too.
Returncoede 500 here too, regardless of whether it is Post Text or Post File

picapportapi/1.0/upload?apisid=FxKw6bePzt5geQJKTnU6E1w4hQiy4fGVdojvfTdwnu8

I didn’t make that connection to the server, okay? So I’m just suggesting.

Make sure that PicApports upload function is configured properly ( upload.* parameter on PicApport-Server Guide

This should work , but
Post File or Text ? word upload 2 times ?

I don’t know if the web support component “multipart/form-data or multipart/mixed stream”.
As far as I know, it can’t.

Thank you Rogerio for taking care

Since the app has not yet been published, I turn off my server in the evening. I think that’s why it didn’t work.

Here is my aia. The ApiSID is determined when the server is online.

Hier mal meine aia. Die ApiSID wird ermittelt, wenn Server online.
upload.aia (10.2 KB)

the API test page also works:
https://sttzr.selfhost.bz/picapport-webapitest.html

Server config:

does anyone else have an approach for a solution?

think this is a great thing to be independent of Google and Co

Hello everybody,

you one more try - but I’ll give up soon - I’m too stupid?

On the API test page I found out the following information about the browser’s developer tool and tried to use it to build a request in blocks. It should actually work. The upload request doesn’t look complicated. Just don’t understand when do I have to build a list, when to join text, when do I have to use Json? Also attached is the app’s error message.

Can someone do something with it?

image

@Rogerio_Rios has already indicated that uploading images with multipart/form-data will probably not work on Kodular, it doesn’t work on App Inventor.

Thanks Tim, I’ll ask if there is another content Type.
Which one would work from your point of view?

How would I have to build the blocks if I could?

Which of my approaches is going in the right direction?

Hello friends,

I found the following picture on my server :slight_smile:

Has anyone uploaded this while trying to help me?

What knowledge was gained?

I still didn’t get any further. Unfortunately, the API provider cannot change the content type.

I would be grateful for your feedback

Change to a new provider…

1 Like

you can give a try to imgbb.com and gladly we have extension in community.

Thanks for the information. But I would like to save the pictures privately on my own server at home and not use an external provider. I don’t know what will happen to my data.
Picapport is a server to install yourself with API support.