Api response

Good evening,

how to recover the data contained in the response of the api, example with api2pdf, it allows me to easily create a PDF but I would like to recover the data present in the response of the server.

Thank you, if you have a tutorial, please share it with me

Hi!

I assume that the api response is the download link.
With File Downloads with Server Connect this tutorial you can set up the file download with the url from the response

This is what I see in my browser when I press F12. I have a response from the server that tells me where to recover my file. I need to retrieve this information to move or copy paste this file on my server.

an idea?

    "api": {
        "status": 200,
        "headers": {
            "0": "HTTP\/1.1 302 Found",
            "access-control-allow-headers": "*",
            "access-control-allow-methods": "*",
            "access-control-allow-origin": "*",
            "location": "https:\/\/storage.googleapis.com\/a2p-v2-storage\/4afeb65c-ecad-4f35-938b-4354b108636f",
            "X-Cloud-Trace-Context": "746f7d4a7343a3efa5435d008fcfb811",
            "Date": [
                "Wed, 16 Mar 2022 20:57:15 GMT",
                "Wed, 16 Mar 2022 20:57:15 GMT"
            ],
            "Content-Type": [
                "text\/html",
                "application\/pdf"
            ],
            "Server": [
                "Google Frontend",
                "UploadServer"
            ],
            "Content-Length": [
                "0",
                "22628"
            ],
            "X-GUploader-UploadID": "ADPycdtYjG2ETWR5XwWxIwEYhjSmHKUBZMC07RQySf50KMuYExoQIpj8mn4QeCVZvKWfcuk8XDBU-2UB5TZnKsEIB2g",
            "Expires": "Wed, 16 Mar 2022 21:57:15 GMT",
            "Cache-Control": "public, max-age=3600",
            "Last-Modified": "Wed, 16 Mar 2022 20:57:15 GMT",
            "ETag": "\"e201c9bfed350bf0a70375c66589458b\"",
            "x-goog-generation": "1647464235754308",
            "x-goog-metageneration": "1",
            "x-goog-stored-content-encoding": "identity",
            "x-goog-stored-content-length": "22628",
            "Content-Disposition": "inline; filename=4afeb65c-ecad-4f35-938b-4354b108636f.pdf",
            "x-goog-hash": [
                "crc32c=sDKE8Q==",
                "md5=4gHJv+01C\/CnA3XGZYlFiw=="
            ],
            "x-goog-expiration": "Thu, 17 Mar 2022 20:57:15 GMT",
            "x-goog-storage-class": "STANDARD",
            "Accept-Ranges": "bytes",
            "Access-Control-Allow-Origin": "*",
            "Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
        },
        "data":
    },
    "api_copy": {
        "status": 200,
        "headers": {
            "0": "HTTP\/1.1 302 Found",
            "access-control-allow-headers": "*",
            "access-control-allow-methods": "*",
            "access-control-allow-origin": "*",
            "location": "https:\/\/storage.googleapis.com\/a2p-v2-storage\/5bf44258-84fa-430d-ad49-c1301c7ed792",
            "X-Cloud-Trace-Context": "a964b4096630736c5f189d63bab83e13",
            "Date": [
                "Wed, 16 Mar 2022 20:57:17 GMT",
                "Wed, 16 Mar 2022 20:57:18 GMT"
            ],
            "Content-Type": [
                "text\/html",
                "application\/pdf"
            ],
            "Server": [
                "Google Frontend",
                "UploadServer"
            ],
            "Content-Length": [
                "0",
                "22628"
            ],
            "X-GUploader-UploadID": "ADPycdtxAUKcExcbDMjz9xB3MiyilD9jaO89nBL2HflAICP-Iy63cSn0E1B-CNAmfF763ub6jaBqvYtNq5K0K60W8FQ",
            "Expires": "Wed, 16 Mar 2022 21:57:18 GMT",
            "Cache-Control": "public, max-age=3600",
            "Last-Modified": "Wed, 16 Mar 2022 20:57:17 GMT",
            "ETag": "\"2ec7aa4a4a8972ee5914ac557965532b\"",
            "x-goog-generation": "1647464237542011",
            "x-goog-metageneration": "1",
            "x-goog-stored-content-encoding": "identity",
            "x-goog-stored-content-length": "22628",
            "Content-Disposition": "inline; filename=5bf44258-84fa-430d-ad49-c1301c7ed792.pdf",
            "x-goog-hash": [
                "crc32c=+QCpMQ==",
                "md5=LseqSkqJcu5ZFKxVeWVTKw=="
            ],
            "x-goog-expiration": "Thu, 17 Mar 2022 20:57:17 GMT",
            "x-goog-storage-class": "STANDARD",
            "Accept-Ranges": "bytes",
            "Access-Control-Allow-Origin": "*",
            "Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
        },
        "data":
    }
}

api.headers.location gives you the download URL for this specific API

You can also check api.status === 200 to see if it succeeded

Thank you but how do I add it to a variable in wappier in my list of header fields I don’t see the location field

When you go to “Define API Schema” you have to make an actual example request to get a real PDF. If you did that and it’s still not showing then either it’s a Wappler bug or you made a mistake somewhere

If you don’t want to bother with it you can just click “Code” and manually type api.headers.location :slight_smile:

Happy to help!

Edit: api.status also doesn’t show there, but that’s a Wappler problem, it doesn’t show everything
Edit 2: Just created a feature request for you

Thanks Apple

would this allow me to see the server’s response live as well as all the data? because there, location does not work even in code

Hi,

No problem!

Regarding your question, I’m not sure if I understand it. api.headers.location returns a link/URL of the PDF file

I am indeed trying to display the link of my file, pdf, but currently with the code you gave me, I have nothing that goes back

even wanting to display the headers to see what could come up, I have nothing, my table remains empty


https://pdf.morganforges.com/index.php
I may not be doing it right

Your Set Value location is wrong, you’re literally outputting “api.headers.location” instead of the actual contents of it

You need to type api.headers.location in the Code section, without any quote marks

Additionally, I’ve just found a Wappler bug in your API response that might affect some of your users:

thank you, suddenly I want to display this variable but it does not work in location, I still have data and headers, in order to display the returned value must I click on data?

I think you just click Code and manually type api.headers.location like in the previous step