0

I am posting xml data to server which is working fine in my local, but after uploaded to server, its breaking the data at client side I hope.

Request payload in my local server

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>xxxxxxxxxxx</ApiKey>
  <Data xsi:type="Subscriber">
    <Mode>AddAndUpdate</Mode>
    <Force>true</Force>
    <ListId>16</ListId>
    <Email>abc@gmail.com</Email>
    <Firstname>abc</Firstname>
    <Lastname>cdf</Lastname>
  </Data>
</ApiRequest>

enter image description here

Request payload after uploading to server

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>xxxxxxxxxxx
  <Data xsi:type="Subscriber">
  <Mode>AddAndUpdate
  <Force>true
  <ListId>16
  <Email>abc@gmail.com
  <Firstname>abc
  <Lastname>cdf

enter image description here

This is integration of ExpertSender. files are hosted in Acquia Cloud.

What could be the possibility of this issue? How can I solve this?

This is my Post call code,

var postData = '<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"><ApiKey>xxxxxxx</ApiKey><Data xsi:type="Subscriber"><Mode>AddAndUpdate</Mode><Force>true</Force><ListId>16</ListId><Email>'+emailVal+'</Email><Firstname>'+firstnameVal+'</Firstname><Lastname>'+lastnameVal+'</Lastname><Properties><Property><Id>1</Id><Value xsi:type="xs:integer">'+telVal+'</Value></Property></Properties></Data></ApiRequest>';
    var postUrl = 'https://api2.esv2.com/Api/Subscribers';
    jQuery.ajax({
        type: "POST",
        url: postUrl,
        data: postData,
        contentType: "text/plain; charset=utf-8",
        cache: false,
        success: function(response) {
            success.html(sucessMsg);
        },
        error: function(response) {
          var xmlData = jQuery.parseXML( response.responseText );
          var message = jQuery( xmlData ).find("Message").text();
          if (message.search("Email is invalid")){
            failed.html(errorMsg);
          }else{
            failed.html(message);
          }
        }
    });
Maistrenko Vitalii
  • 994
  • 1
  • 8
  • 16
PonrajPaul
  • 174
  • 1
  • 7
  • 18
  • 1
    There's a lot of missing information here. How are you creating and executing the POST request? How is the request payload created? Are you manually setting the `content-length` header? – Phil Mar 22 '18 at 00:27
  • @Phil, I updated my question with jQuery code what i am using – PonrajPaul Mar 22 '18 at 00:33
  • 1
    Does your production code go through any JS minification or other sort of processing before being deployed? Have you tried stepping through with your browser's debugger to make sure the `postData` variable contains the expected value? – Phil Mar 22 '18 at 00:41
  • 1
    @Phil, Oh Man, I just saw now. its automatically trimmed with minification. I was breaking my head from last 8 hours. Thanks a lot bro. I will find the reason in minification settings. Thanks a ton. – PonrajPaul Mar 22 '18 at 00:48

1 Answers1

0

It was the text editor configuration.

In Drupal-8, the "mail text" text editor's "Correct faulty and chopped off HTML" option actually doing crazy with XML content.

enter image description here

PonrajPaul
  • 174
  • 1
  • 7
  • 18