You have to work on the web response from the outside in,
saving intermediate results in global variables as stepping stones to help spot where you fail.
From the outside in, you have a JSONresponse object with tag “En-têtes de la réponse (223 o)” and value an object with headers a list under tag “headers”.
I just tried both Web Jsondecode blocks on it, and got back empty texts, so we will have to fix the text, (On further inspection the JSON text you posted ended up with non-JSON slanty quotes, which need to be replaced with straight quotes.)
Hello, thanks a lot for your work, but my problem is still not solved. You wrote into the variable “webResponse” directly the response, but I need to get it from the response header, updated each time I start the app. The cookie credentials I get is available only during 15 minutes. Can you tell me how I can get the header, without writing it into a variable ? Thank you
I don't know if this will work for you ... in this discussion there is an extension called: com.KIO4_Terminal.aix
With this extension you can use many LINUX commands
Some devices have the curl command.
Can you test if this instruction works for you?
Terminal.Run
commandLine: curl -I https://www.keycdn.com
Hello, everyone ! I think I haven’t explained well my problem. I want to perform a PUT request to a server to get a cookie credentials, which is in the header of the response. The PUT request works well on my program, I can send the request, and I get the body of the response. That’s my problem. I don’t know if it’s possible to get the response header in AppInventor, and if it is, tell me how to do it. Thank you.
Because the web component cannot return header responses from a server, instead you could possibly use Juan’s terminal extension to send a curl command instead, which might return the header responses you are after. You would need to have curl in your /system/bin for this to work.
well, the web component is not able to do what you want
your only option as far as I know is to try the extension as already mentioned together with the corresponding curl command
you might want to try it... it is your choice...
So I have installed your extension @Juan_Antonio ( well done, great job by the way ).
and played around with it a bit.
I've replace the all the commands in your "commands.txt" with only one line, being the curl command I need and uploaded the file again.
After I installed curl on my win10 computer, it worked just fine and I got the headers from curl.
So I tried that command in the emulator or your "Extension_Terminal" @Juan_Antonio , didn't work.
Compiled from the .aia and it didn't work either on my phone.
So I guess, as TIMAI2 says:
You would need to have curl in your /system/bin (on your phone) for this to work.
if curl can be installed on the phone (if it's not already on it, that is) and in combination with the "KIO4_terminal" extension, the ResponsHeaders might be retrieveable.
It might be a work-around....
To bad the "Web" component can't be used directly to retrieve the ResponsHeaders.
If you control the number of requests you make (to under 120 per minute) you should be OK, i can’t see a reason for needing these back from the server…
Yes, indeed, correct.
But when for example the app uses a “slider” to control the brightness of the lightbulb, it needs to be on the fly, sending each time a http-request.
Tried the “ls /system/bin” command, but came up empty, although “system” isn’t.
also tried the “curl --version”, which didn’t show anything.
EDIT: Guess the slider is off for the moment and as you’ve stated, I’ll control it myself.
Although I find the extension very usefull. See if I can play around with it, later on.
so, I don't know if it solves your problem, but I had a similar problem during working throught this great tutorial of METRIC RAT AI2 (see link below) and solved it with text manipulation. Firebase with a web component
Saying in advance, my solution only works if the syntax of the response content is always the same (you need to proof that in advance!), therefore it's a little bit risky!
Here comes my solution:
I sent authentification data (should also work with PUT/PUSH/GET/DELETE into a database, just a different URL) into a Firebase console via a web-component.
I do not use the experimental Firebase tool, just pure URL-stuff.
Doing so I was able to read the responses via a programmed "set variable to response-content of the web-component"-function (don't know how it it's exactly called, look into the screenshots, you'll see what I mean).
Afterwards I read the strings of the variables, which contain the web-component responses and always have the same syntax.
Let the "starts at"-function search for the exact starting positions of key-headers before and after your content and add or subtract the numbers to the starting-/ending-position of your content.
It's a little bit of trial and error, that's why I displayed everything on the screen with labels, the pure response and my text-reading-results, to see which numbers work, but in the end it worked.
What I get as a result is the exact start and lenght of the content, so that I'm able to set variables to exact this content with the "segment"-function.
If you want to use those contents, you can easily join the contents into a URL to PUT/PUSH/GET/DELETE content in your database.
Edit: If for some reasons your database doesn't allow data-manipulation throught URL-requests, this solution will not work. Instead, you can use a Javascript file running on a server, which can be called with the webviewer component.