Remove "+" character and replace with whitespace in Json conversion

How to remove "+" Character and replace with whitespace in between two words in JSON request. We're using Apigee with Drupal 7 . We have more than 200 API running via Apigee for our developer portal. I tried with split and join functions with regex. But it doesn't work. I want to fix this issue with JavaScript.

0 3 1,864
3 REPLIES 3

@LOKESH KUMAR RAVI

Have you tried using the replace function on the request content?

var payload = context.getVariable("request.content");
var updatedPayload = payload.replace(/\+/g, " ");
context.setVariable("request.content", updatedPayload);

Sample attached 16377-replacestring-rev1-2019-04-22.zip

js-replace.jpg

but in apigee when i used replace() method then i got these error : -  with error: Javascript runtime error: "TypeError: Cannot find function replace in object mitc.

To get help on this, you will need to show your code. 

The replace() function applies to a string. The error you are showing suggests that you've invoked it on a think that is not a string. It is a n object of some other type.  That is the source of the error.  You'll need to show your code to get more specific help.