POST request to a specific API

I’m trying to use an API wich require base64 images. Documentation is here : API Documentation – Masala.AI (section “POST mediaratingb”)
I tried several blocks, but the best I get is the API returning me “internal error, plz contact support”, but support is telling me that there is no pb on their side

May you validate that my blocks are correct, before I move to another API ?
(I read App Inventor Tutorials and Examples: Dropbox | Pura Vida Apps tutorial and How to make a post request to this API? and How to request HTTPS Post request but didn’t solve my pb)

I tried :


If someone has a tutorial to translate CURL demo code to kodular blocks, I would be very happy.

A. R.

Precision :
I cannot upload the image and use an URL, for privacy concerns (my app is about testing image with potentially the user naked on it, for NSFW verification).

according to the documentation

“payload”: “b’/9j/4AAQSkZJRgABAQEAYABgAAD/2wBD…’”

it looks like you should use your trial number 4, and don’t forget to add the b’/ prefix …
also you might want to use Do it to debug your blocks…


"Accepts an image as a public URL in a JSON "
Or change your string in the JOIN in image 4.

1 Like

Thx, I was thinking “b’/” was part of the base64 encoding of the image.

Thx for “do it” tips.

Unfortunately it still does not work, but now I know that this is the API not working, not my blocks.

Thx to both of you, I’m going to try other API then I close this issue.

I just realised I have given my API key accidentally in previous images ^^

Place the API address where an address is in the image. Then click on content and place that example JSON from the API website. You will also ask for your API KEY (it happened to me and I didn’t create the KEY). Then click on SEND. The box on the right has the API RETURN options.

I didn’t use it :+1:

are you sure?
you might want to post a screenshot with your latest relevant blocks including Do it result

1 Like

Here is the test conducted with @Rogerio_Rios :

Status:500 (Internal Server Error)Time:155 msSize:0 kb

“ErrorCode”: 500,
“ErrorMsg”: “Internal application error, please contact support”

It really seems to me the API is down

Here is another test with another API that doesn’t require uploading the image to an url (API Documentation -

The second “text” contains :

", “API_KEY”:“xxxxxxxxxxxxxxxxx”, “task”:“suggestive_nudity_moderation”}

I’m again getting an error :

errorCode 10, error message : API key is missing
Should I put the API key in headers ??? i don’t understand the doc

I’m truly sorry, I worked with API in python a few times, but it was pretty simple (copy&paste code), here I’m really lost. If I don’t succeed with this API, I will take a lesson about CURL to be able to read the options.

Here is the “do it” for new API (with API key obsfucated)

Do It Result:
{“file_image”:"/storage/emulated/0/takenPicture.jpg", “API_KEY”:“xxxxxxxxxxxxxxxxxxxxx”, “task”:“suggestive_nudity_moderation”}

Did you test without { } ?

I tested it. Same result

Ok, I’ve done something very inelegant, but it works : I have copied the JS code and used it in the “evaluate” of a WebBrowser sized 0x0 to be invisible.

At least, if we can’t solve the POST issue, I’ve something which is working

JS code?
Webbrowser sized 0x0 ?
Sorry, but I didn’t understand anything… :joy:

:wink: I understand, not my most cristal-clear explanation.

The API website proposes code in python/javascript etc.
While I can’t easily run python on phone, js is ez with webviewer “evaluate” function.

SO I execute the code in a webviewer, which I don’t need the user to see, so I make it invisible.

Clearly a poor work-around, but it is working.

1 Like