-1

Is this a valid URL? Should the character "|" be included in it? Sure, this works but I don't think it's the right way to do it

https://sales-stage-api.techsg.cloud/requests/statistics?"meetingTime"|date:timeZone={"start":"2022-02-01 00:00:00 +07:00","end":"2022-02-28 23:59:00 +07:00"}
TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

A Vertical Line (U+007C) should never appear in the query part of a URI, because it is not consistent with the production rules defined in RFC-3986

query         = *( pchar / "/" / "?" )
pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
              / "*" / "+" / "," / ";" / "="

Note that the spaces and braces are also suspect.


Key/Value pairs in the query string are normally an indication that they are an application/x-www-form-urlencoded representation of some information (for instance, values collected from HTML Form input controls); so you'll usually want to ensure that the serialization of that information matches the deserialization.


What spellings should be used for keys and values (before serialization/after deserialization) is largely a local design concern: the origin server controls its own space of resource identifiers, so if it wants to have some name like:

"meetingTime"|date:timeZone

Then that's fine? It's tradeoffs - you give up something, and get something else in return; if the thing you get is more important than the thing you are giving up, then you are winning.

That said, I haven't the foggiest idea what this designer thinks they are getting in return, that offsets the assorted miseries that this spelling convention introduces.

This is not a design that would make it through my review process without a lot of supporting documentation.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • Thank you for your detailed answer. This is from the backend side of a company I've just started working for. They use nodejs on server side and apparently this is the way they query/draw data from their databases, I think they use the whole parameter's name as a query. I've seen similar things like `title|like` or `date|gte` and such as a parameter. I think they use it for convenient purpose, just use they parameters as query straight up, don't have to do anything else in between – Khang Hồ Mar 10 '22 at 01:55