If you are using JavaScript/TypeScript, you can do this:
const encodedQP = encodeURIComponent(encodedQP);
encodeURIComponent() ensures that special characters (like /, ?, &, etc.) are encoded safely for URLs and will not break you API requests.
Here's a link to its documentation.