0

Good afternoon.

I am currently working with an API of the GET type in which we must use the following url for the get method as standard:

/users/{user_id}/customers

The question here is that I don't know how I can get this value, if I can only use RequestMapping and if so, my user_id input parameter is a combination of the Query Parameters type like the following example:

/users/user_id?id=1&value=12345678/customers

That is, can I retrieve the query parameters from the user_id field as indicated in the example url or can this only apply the query parameters to the end of the URL?

Cesar Justo
  • 707
  • 2
  • 11
  • 35

2 Answers2

0

There is an RFC for the Uniform Resource Locators, which defines a form.
RFC 1738 - Uniform Resource Locators (URL) – Section 5 – BNF for specific URL schemes.

The BNF for httpurl is defined as follows.

httpurl        = "http://" hostport [ "/" hpath [ "?" search ]]
hostport       = host [ ":" port ]
hpath          = hsegment *[ "/" hsegment ]
hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
search         = *[ uchar | ";" | ":" | "@" | "&" | "=" ]

uchar          = unreserved | escape
unreserved     = alpha | digit | safe | extra
escape         = "%" hex hex
safe           = "$" | "-" | "_" | "." | "+"
extra          = "!" | "*" | "'" | "(" | ")" | ","

"... can I retrieve the query parameters from the user_id field as indicated in the example url or can this only apply the query parameters to the end of the URL?"

It would appear that you would, most likely, not be able to utilize that form.
The parameters would be part of the hsegment field, which does not typically allow for a ? character.

Reilas
  • 3,297
  • 2
  • 4
  • 17
0

I'm pretty sure the syntax you may want to use is not supported (or you have to encode/decode data by youself), but what about using matrix param?

/users/user_id;id=1;value=12345678/customers

Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69