How do i dynamically create the URL for GetRemote?

I seem to be having a problem with dynamically creating the url. How do i dynamically update the URL Path?

This works fine:

{{ with resources.GetRemote "https://example.com/API/v1/data/12345678/reports?per_page=1&page=1" $opts }}

This fails:

{{ $guid := 12345678}}
{{ with resources.GetRemote "https://example.com/API/v1/data/$guid/reports?per_page=1&page=1" $opts }}

also fails:

{{ $guid := 12345678}}
{{ $url "https://example.com/API/v1/data/$guid/reports?per_page=1&page=1" }}
{{ with resources.GetRemote $url $opts }}
{{ $guid := 12345678}}
{{ with resources.GetRemote ("https://example.com/API/v1/data/%d/reports?per_page=1&page=1" $guid) $opts }}

[/quote]

Use printf.

2 Likes

thanks @bep that worked :heart_eyes:

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