Search code examples
javaandroidpathauthorityauthoritykeyidentifier

Is the "api" part of a Web API route considered by Android's Uri.Builder as part of the authority or a path?


I've tried both of these:

builder.scheme("http").authority("10.0.2.2:28642").appendPath("api").appendPath("DeliveryItems").appendPath("PostArgsAndXMLFileAsStr").

builder.scheme("http").authority("10.0.2.2:28642/api").appendPath("DeliveryItems").appendPath("PostArgsAndXMLFileAsStr").

...and although for other reasons the code is not working yet, I'm wondering which way is right:

.authority("10.0.2.2:28642").appendPath("api").

-or:

authority("10.0.2.2:28642/api").

?


Solution

  • The "authority" portion of a URI identifies who's responsible for specifying the semantics of the path portion. This is usually a host/port combination and can optionally include a username/password (as in http://user:pass@host:port/somepage).

    Wikipedia has more details on the grammar of URIs.