obsidian-api-request icon indicating copy to clipboard operation
obsidian-api-request copied to clipboard

Mixing up frontmatter values?

Open sij-ai opened this issue 1 year ago • 3 comments

Describe the bug It seems the extension is mixing up frontmatter variables/values. The following in Obsidian:

---
date: "2024-04-17"
zip: "97401"
banner: "![[obsidian/banners/2024-04-17.jpeg]]"
tags:
  - daily-note
---
#  [[2024-04-16 Tuesday|← ]]  Wednesday April 17th, 2024 [[2024-04-18 Thursday| →]]

` ` `req
url: https://api.lone.blue/note/weather/{{this.date}}?zip={{this.zip}}&api_key=sk-REDACTED
headers: { "Authorization": "Bearer sk-REDACTED" }
response-type: md
` ` `

results in the following API request: "GET /note/weather/2024-04-17?zip=2024-04-17&api_key=sk-REDACTED HTTP/1.1" 404 Not Found

As you can see, it's reusing the date instead of sourcing the zip. This happens regardless of whether the date is a string or a date object, or whether the zip is a string or a number.

To Reproduce See above.

Expected behavior "GET /note/weather/2024-04-17?zip=97401&api_key=sk-REDACTED HTTP/1.1" 204 OK

Desktop (please complete the following information):

  • OS: macOS Sonoma
  • Version: Obsidian 1.5.12, API Request 1.2.3

sij-ai avatar May 14 '24 02:05 sij-ai

I came up with a silly workaround that I thought might be helpful in tracing the source of the issue:

url: https://api.lone.blue/note/weather/{{this.date}}?dummy=true;zip={{this.zip}}
headers: { "Authorization": "Bearer sk-REDACTED" }
response-type: txt

fixes it. It evidently doesn't like to have query parameters in a row sourced from the frontmatter?

edit -- err, evidently the relevant change that fixes it is actually using a ; instead of &

sij-ai avatar May 14 '24 02:05 sij-ai

I had harcoded an index, that's why only one variable ({{this.date}}) was displayed.

Could you check if this is fix for you?

Rooyca avatar May 14 '24 06:05 Rooyca

Hey @iodrift, I would like to know if your problem was solved and if we can close this issue.

Rooyca avatar May 17 '24 17:05 Rooyca

It's fixed, thank you sir!

sij-ai avatar May 20 '24 05:05 sij-ai