0

I want to post a json string from brower like this:

{"user_name":"lined%"}

But when I read the content from the action, it just raise a exception :Error decoding URL style (%XX) encoded string at position 6

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  RequestContent :string;
begin
  RequestContent := Request.Content;
end;

The percent sign % in the json string cause this exception.

My solution is make the request content to base64 format, I think it's not good.

Any advice would be greatly appreciated, Thanks.

Lin Andy
  • 11
  • 1
  • Exactly *how* is that JSON being sent. You said from a browser, but you do not say whether it's part of the URL, part of a form or anything like that – Dave Nottage Jul 12 '22 at 06:17
  • That's because your JSON is sent with `Content-type: application/x-www-form-urlencoded` and thus gets [percent encoded](https://en.wikipedia.org/wiki/Percent-encoding), while [it should be sent as `Content-Type: application/json`](https://stackoverflow.com/q/9870523/4299358). – AmigoJack Jul 12 '22 at 10:37

0 Answers0