Rooyca / obsidian-api-request

Obsidian plugin that allows you to make requests to API's and receive responses in codeblocks or store them in localStorage.
https://rooyca.github.io/obsidian-api-request/
MIT License
78 stars 4 forks source link

Tries to parse markdown as JSON, fails #17

Closed sij-ai closed 2 months ago

sij-ai commented 2 months ago

Describe the bug I have a custom private API script for tracking my billable hours, which includes an endpoint that outputs my timeslips for the day in a neatly formatted markdown table. APIRequest doesn't seem able to parse it as markdown, instead consistently failing with Error: Unexpected token '|', " |Project|T"... is not valid JSON

To Reproduce Steps to reproduce the behavior:

I can't share my actual timekeeping API but I set up a dummy script to illustrate the problem:

curl https://temp.sij.law/table

| ID | Name      | Email            |
|----|-----------|------------------|
| 1  | John Doe  | johndoe@mail.com |
| 2  | Jane Smith| janes@mail.com   |

^ all well and good, but:

` ` ` req
url: https://temp.sij.law/table
response-type: md
` ` `

yields this: Error: Unexpected token '|', " | ID | Nam"... is not valid JSON. Feel free to test it using that URL, I'll keep it online for a bit.

Expected behavior A markdown table would appear.

Screenshots N/A

Desktop (please complete the following information):

Additional context I also tried changing the API to wrap the markdown in a {"markdown": {{markdown_content}}} JSON output, and tell APIRequest to show the contents of "markdown". It does show the contents, but just as a block of text, \n and all -- not properly formatted markdown.

Rooyca commented 2 months ago

Hey @iodrift, I believe is done! Please tell me if it works to you.

sij-ai commented 2 months ago

edit - yes! it works now. Thank you very much for the very quick fix :)

Rooyca commented 2 months ago

yes! it works now.

Glad to hear that.

Thank you very much for the very quick fix :)

My pleasure. :smile: