Encode URL Special Characters

In SCAPI, the comma (,) is used as a value separator and percent sign (%) is used for URL encoding.

These characters are treated as reserved characters and must be additionally URL encoded in UTF-8 when used within the following resource identifiers for SCAPI requests:

  • Request path parameters
  • Query parameters

for example: productID, categoryID, and promotionID.

Request Path Parameter Encoding 

If a comma (,) or percent sign (%) is contained within resource identifiers in request path parameter values, the values must be additionally URL encoded in UTF-8. The following example shows a request for the productId resource identifier: “Flour,1KG”:

1`curl "https://{shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/{organizationId}/products/Flour%2C1KG"`

When the client submits the request, the request is usually automatically encoded one more time by the HTTP library and sent to SCAPI:

1https://{shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/{organizationId}/products/Flour%252C1KG

SCAPI decodes the resource identifier in the request:

1ProductId -> "Flour,1KG"

Query Parameter Encoding 

If a comma (,) or percent sign (%) is contained within resource identifiers in query parameter values, the values must be additionally URL encoded in UTF-8. The following example shows a request for the productId resource identifier: “Flour,1KG” and “1%Milk”:

1`curl "https://{shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/{organizationId}/products?ids=Flour%2C1KG,1%25Milk`

When the client submits the request, the request is usually automatically encoded one more time by the HTTP library and sent to SCAPI:

1https://{shortCode}.api.commercecloud.salesforce.com/product/products/v1/organizations/{organizationId}/products?ids=Flour%252C1KG%2C1%2525Milk

SCAPI decodes the resource identifier in the request:

1ProductIds -> "Flour,1KG"
2           -> "1%Milk"

We generally recommend NOT using special characters like commas (,) or percent signs (%) within resource identifiers.

Note