Nested External API Looper - Looper Key In Endpoint

I have an external api looper (endpoint: https://www.zohoapis.com/inventory/v1/packages )that works correctly and displays a looper field key {{dc:looper:field key=“salesorder_id”}}. Then i have a div inside that div and I want to call another endpoint with the looper field in the api endpoint. https://www.zohoapis.com/books/v3/salesorders/{{dc:looper:field key=“salesorder_id”}}/… but the {{dc:looper:field key=“salesorder_id”}} is not working the the api endpoint.

Should this set up be able to work correct?

< div >api endpoint https://www.zohoapis.com/inventory/v1/packages
— < div > api endpoint https://www.zohoapis.com/books/v3/salesorders/{{dc:looper:field key=“salesorder_id”}}/
---- < div >
< div >

Hello There,

Please make sure to run the Looper Consumer first:

< div >api endpoint https://www.zohoapis.com/inventory/v1/packages (looper provider)
  < Div > Looper Consumer
         — < div > api endpoint https://www.zohoapis.com/books/v3/salesorders/{{dc:looper:field key=“salesorder_id”}}/
---- < div >
   < div >
< div >

If this does not work, please provide us with your WP details so we can check your looper settings. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Cheers.

Thank you. That helped sort it out.

One more question. Through the looper api, i’ve build a url to a file that i would like a button to download. However the permissions doesn’t allow for a url in a button, it want a get request to download. Is there a way to accomplish that in cornerstone with the external api looper?

For example a url is dynamically build, example https://books.zoho.com/api/v3/invoices/{{dc:looper:field key=“invoice_id”}}/documents/{{dc:looper:field key=“documents.0.document_id”}}

I would like an on click event to make that a get api request? Maybe with a div that has that url as the external looper api? Is that possible?

Hey There,

Regretfully this isn’t possible already. You will need to have a click event trigger for an AJAX call to get the API Request. Be advised that custom coding is beyond the scope of our support under our Support Policy.

Best Regards.

Currently I would recommend sending a click to another page if possible. Using a URL parameter in the link you could use that data to make another request that displays the data you need on another page. Let us know if that helps of you need me to elaborate. Have a great day.

Smart idea using url parameters!

I did a little initial testing and set up the button url to add the get request url as a parameter, which works.

I set up an an api tester cornerstone field with the get url from the url parameter. Also works. However, thats where i’m stuck. How do i get the download of the get request to occur?

Do i need to add something equivalent to --output “doc.pdf” in the cornerstone api tester? If so, how?

**Update, i changed the return type to file return, which does appear to generate a url to the file request saved in /wp-content/uploads/cornerstone/external-api/(file name). How do i download or view that file on page load? Is there a way to download the file of view without saving to the server? Is this the right direction I should be heading?

1 Like

Yes using file return is probably what you want. So when you have that File Return looper setup and have a looper consumer. You can pass it into a button or a link using {{dc:looper:item}} which will be the URL. Or if you setup a custom attribute called download, you can also have the browser download it with the given value set for that attribute. Let us know if this helps.

image

image

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