Dear, good afternoon, could you help me with this case.
I am trying to replace %20 by spaces, the idea is that this code should be with two spaces to work correctly, javascript successfully replaces the two %20 by two spaces, but when I see what goes in the request, the code only goes with a space, I do not know if it is at the time of making the context.setVariable, but I deleted a space.
request = context.getVariable("request.content");
print(request);
print('----------------------------------------------------------------------');
request = request.replace('%20%20', ' ');
print(request);
context.setVariable("request.content", request);
Solved! Go to Solution.
Hi
I understand what you wrote. And also, I would be very very surprised if Apigee is causing the unexpected observation you described. There is something else happening.
I suggest that you break down your problem, simplify it, and re-check your observation. Simplify the situation as much as possible. Don't use the large XML file, use a simple one, with just one element. Don't use the final target, use a simple echo server. When I do this, My observation is that the string replacement works as expected.
without string replacement:
<response>
<body>
<Inquiry>
<Emplid>
<Emplid>123%20%20456</Emplid>
</Emplid>
<Languages>
<Language>English(Speaking)</Language>
</Languages>
</Inquiry>
</body>
</response>
with string replacement:
<response>
<body>
<Inquiry>
<Emplid>
<Emplid>123 456</Emplid>
</Emplid>
<Languages>
<Language>English(Speaking)</Language>
</Languages>
</Inquiry>
</body>
</response>
This is all as expected, from my point of view.
There is something else in your environment causing the surprise (missing one space) that you are observing.
Hi
I understand what you wrote. And also, I would be very very surprised if Apigee is causing the unexpected observation you described. There is something else happening.
I suggest that you break down your problem, simplify it, and re-check your observation. Simplify the situation as much as possible. Don't use the large XML file, use a simple one, with just one element. Don't use the final target, use a simple echo server. When I do this, My observation is that the string replacement works as expected.
without string replacement:
<response>
<body>
<Inquiry>
<Emplid>
<Emplid>123%20%20456</Emplid>
</Emplid>
<Languages>
<Language>English(Speaking)</Language>
</Languages>
</Inquiry>
</body>
</response>
with string replacement:
<response>
<body>
<Inquiry>
<Emplid>
<Emplid>123 456</Emplid>
</Emplid>
<Languages>
<Language>English(Speaking)</Language>
</Languages>
</Inquiry>
</body>
</response>
This is all as expected, from my point of view.
There is something else in your environment causing the surprise (missing one space) that you are observing.