Dynamic options via JSON API for select field using Query Language

I’m trying to use the api option on a select field to get values from an external json, but can’t get it to work. I have added the json url in a field on the same page and want to use that value for url.

This is my blueprint:

title: Tag feed
preset: page
    label: Produktfeeds
    type: text

    label: Taggmappning
    type: structure
    sortBy: feed_name asc
        label: Feednamn
        type: select
        options: api
          url: {{ page.products_feed.toString }}
        label: Tag
        type: radio
        options: query
          fetch: page.parent.tags.toStructure
          text: " {{ structureItem.tag }}"
          value: " {{ structureItem.tag }}"

The panel get me an error:
Argument 1 passed to Kirby\Toolkit\Str::template() must be of the type string or null, array given.

Does the .toString not work when using Kirby Query Language?

You should use query string in double quote like that:

  url: "{{ page.products_feed.toString }}"

Btw as far as I remember, you don’t need to use toString() method.

Thanks. The Panel stoped reporting error but the select i empty. If I copy the URL from the products_feed field and use it as url in my blueprint i works. So something is wrong… How can I debug the value from the field to see what’s going on?

Maybe it’s just not possible. I tried different variations and the only one I could get to work was either to hard code the URL or use the dynamic example from the docs.

So it might only work if the json file is stored as a local file?

Tried to upload the json to the page in panel and in blueprint url: " {{ page.file }} " but no luck.

The url option really wants a URL, not a file object. I don’t have time now, but maybe it would be possible with using a query instead of the API, and then in the query call a page model which in turn calls the URL in the field, reads it and return the options. Seems that the API option is not a flexible as one would expect.

I see. I will try an other solution then. Thanks for the input.
Also I noticed when I hardcoded the url in the blueprint so the select field worked, the panel got really slow…

Should I add this at Github as a bug or a feature request?

Yes, please, feature request