Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying for inscriptions by >1 mime_type fails due to incorrect enconding #254

Open
sabbyanandan opened this issue Oct 20, 2023 · 4 comments
Assignees

Comments

@sabbyanandan
Copy link

From Nima:

Hi, I'm trying to execute an api call as described on https://docs.hiro.so/ordinals/list-of-inscriptions

I'm adding two different mime type parameters in your API tester and the final call looks like this in the curl box: curl -L 'https://api.hiro.so/ordinals/v1/inscriptions?mime_type=image%2Fpng%2Cimage%2Fjpeg' \
-H 'Accept: application/json'

But when I execute the call I get this error:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "querystring/mime_type/0 must match pattern \"^\\w+\\/[-.\\w]+(?:\\+[-.\\w]+)?$\""
}

But I'm using your own API tester to do this and following all the instructions as far as I can tell.

How can we eliminate this error?

An example of a correctly encoded URL would be:

curl -L 'https://api.hiro.so/ordinals/v1/inscriptions?&mime_type=image%2Fsvg%2Bxml&mime_type=image%2Fapng'
-H 'Accept: application/json'


The API demo panel in the Docs is not correctly encoding the special chars in the query param. But it could also be due to how the OpenAPI spec is designed. Therefore, I am opening the issue in the Ordinals API so we can verify it here first.

@diwakergupta
Copy link
Member

Here's an example from the tests:

        const response3 = await fastify.inject({          method: 'GET',
          url: '/ordinals/v1/inscriptions?mime_type=image/png&mime_type=text/plain',
        });

Note the repeated mime_type -- I don't think the request is failing due to an encoding issue, it seems like it's failing because the 2nd mime type is provided without the mime_type argument.

@sabbyanandan
Copy link
Author

@diwakergupta: Oh! Thanks for catching that. I blindly copied the URL from the dev console (through Ordinals Explorer) and included that in the example I listed in the description. I didn't pay close attention to the multiple mime_type pairs.

@nima1981
Copy link

Here's an example from the tests:

        const response3 = await fastify.inject({          method: 'GET',
          url: '/ordinals/v1/inscriptions?mime_type=image/png&mime_type=text/plain',
        });

Note the repeated mime_type -- I don't think the request is failing due to an encoding issue, it seems like it's failing because the 2nd mime type is provided without the mime_type argument.

Correct, current API documentation states to use a comma to separate the values and the API tester implements this non functioning format.

See the line "Example: image/png,image/jpeg" at https://docs.hiro.so/ordinals/list-of-inscriptions

@sabbyanandan
Copy link
Author

Aside from the OpenAPI spec and the related documentation issue, @nima1981 wonders (as a new feature request) whether the Ordinals API can support either of the following formats:

a: "comma separated" values
b: a regex

@andresgalante andresgalante moved this from 🆕 New to 📋 Backlog in Ordinals Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants