How to save response of Web component even if error 400 is returned?

Hi!
I am new to Kodular and I love it! But I have a problem. When I call my API it returns 400 error on wrong input and information on what went wrong (I want to get 400 when something is wrong). I send a request to my API using Web component, but when web1.GotFile is called, file in which info should be saved does not exists.
How could i get content of web response?
Thank you for your hep!

if you use the GotFile event, then you will find the response in the downloaded file
Taifun

1 Like

Taifun Yes, I tried. I have it.
image

But it doesn’t work if response is anything other that 200.

Did You check This parameters ?

Yes. FileName returns a file that does not exist. I checked through filesystem and using File1.Exists…
responseCode is 400 as I want it to be…

Do you want it to be code 400?

400 Bad Request Error: What It Is and How to Fix It · Airbrake.

Yes. I want it to be 400. It should be. Because user has sent wrong text.

to debug this you might want to display the filename in a label, let us know, what you find out…
probably the path should be modified so the file component will then be able to read it?

Taifun

Hi!
Web1.GotFile fileName returns: " /storage/emulated/0/My Documents/Downloads/app_inventor_1605564580403.html"
And file does not exists on my phone…

But if Web1.GotFile responseCode is 200 (returns wav recording), then the filename is: “/storage/emulated/0/My Documents/Downloads/app_inventor_1605565177181.tmp”.

Thank you

are you sure? how did you check this?
to read that file using the file component you will have to remove the /storage/emulated/0 to get a relative path for the file component…
this filename should work for the file component:
/My Documents/Downloads/app_inventor_1605564580403.html
EDIT: but as it is a html document probably better to use a webviewer to display it… in this case use the full path…

Taifun

Taifun it works now!!
Thank you!
I didn’t know that File1.Read can’t handle /storage/emulated/0 absolute path.

I have learnt something new today…

Sincerley

How You Solved ?
It is important to show to help others. And mark your solution. :thumbsup:

this is the solution

Taifun

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.