Custom API Template: .JSON.Array fails to access array directly under top-level key using path #597
-
Description I'm encountering an issue with the Custom API template feature in Glance when trying to display data from a JSON response where the main list/array is located directly under a top-level key. The template syntax Expected Behavior The template expression Actual Behavior When the JSON response contains the array directly under the
Steps to Reproduce
Illustrative Examples Working Scenario (Signatures - array nested): This scenario works correctly, where the array
Failing Scenario (DNS Records - array directly under key): This scenario fails when the array is the direct value of the
Or maybe there is another way do so? Best regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
{{ range .JSON.Array "" }}
I think I may have misunderstood the issue initially. I tried replicating with the data and template you provided, but it's working as expected: It looks broken since you've specified Can you add the following to your template to verify that you're getting the expected response? {{ .Response.StatusCode }}
{{ .JSON.String "" }} It should output the status code and response body. |
Beta Was this translation helpful? Give feedback.
-
@svilenmarkov , my baaaaad ! clearly showed me that the Authorization key i was using didn't allow to parse the api for retrieving dns records (permission issue)! i didn't use the Authorization i was using with curl and Bruno............. now using the initial template is working :)
Thank you very much for your helpful hint, i am learning every day :) Have a nice week-end |
Beta Was this translation helpful? Give feedback.
Hey, to access a top-level value or the value of the current context, use an empty string as the key:This is documented here. I know it's not the most intuitive thing at first, but I didn't want to introduce a separate function just for this case.I think I may have misunderstood the issue initially. I tried replicating with the data and template you provided, but it's working as expected:
It looks broken since you've specified
data-collapse-after="0"
, but if you change it to 5 for example and remove the comments, you get what you expect:Can you add the following to your template to verify that you're getting the expected response?