My Products
Help

Method for getting resources with reserved characters - B64URL Encoding

11-01-2021 13:06
  • 1 Replies
  • 0 kudos
  • 2020 Views

Since version 8.19 (18.02.2020), a method for retrieving resources with base64url encoded values has been available for all resource endpoints.

 

This makes it possible to use characters otherwise reserved in URL, i.e:
: / ? # [ ] @ & * + ; 

To use it, one simply adds b64(encodedValue) in place of the resource name when you make your request.

 

Below is an example of how this works.

Inventory item with several reserved characters:

2020-09-11 09_02_19-Non-stock items.png

Getting this without encoding the resource name will result in an error:

GET /Inventory/:/?#[]@&*+;

 

If you instead encode the value with base64Url encoding: :/?#[]@&*+;  ⇾ Oi8_I1tdQCYqKzs, and insert it in the b64 method you will get the wanted item:

GET /inventory/b64(Oi8_I1tdQCYqKzs)

2020-09-11 10_25_03-Postman.png

 

If you want to read more about base64Url encoding, please have a look at the following links:

RFC 4648 § 5 
Base64Guru

base64encode

Comments
mrbk
CONTRIBUTOR *
by mrbk (Updated ‎08-02-2022 09:48 by mrbk )

Why are you doing it this way?

RFC 3389 clearly specifies path encoding rules for such cases:

https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3

 

Every properly implemented client will support this.

And every competently implemented server code will aswell.

 

Specifically, your example sku :/?#[]@&*+; will yield the uri path /api/v1/inventory/:%2F%3F%23%5B%5D@&*+; according to rfc3986 3.3.