0
I am consuming an API (POST), via Delphi for sending NF-e XML. I am using Httprequest.
In the body of the request (body) I must pass the xml as follows: xml=
But the issuer’s social reason (xName) contains the special character "&". By sending the information to the API it returns an error:
Note XML with broken or invalid syntax: Premature end of data in tag xNome line 1
From what I understand, the API is understanding that this & refers to a new parameter, breaking the XML string.
How do I send information with this special character "&" so that the API does not understand as parameter but as text/string of Xml?
My code is like this:
Request.Uri := BASE_URL + '?token='+ FToken;
Request.Method := 'POST';
Request.Headers.SetValue('Accept', 'application/xml');
Request.Headers.SetValue('Content-Type', 'application/x-www-form-urlencoded');
Request.Headers.SetValue('Authorization', 'Basic '+EncodeString(Format('%s:%s', [FUsuario, FSenha])));
Request.SetContent(TEncoding.UTF8.GetBytes(Concat('xml=', FXML.Text)));
Try to change the
&
for&
and see if it resolves.– Matheus Ribeiro