Understanding character encoding on the API

Discussion in 'Developers Forum' started by phillip, May 20, 2011.

  1. phillip New Member

    Hi All,

    I've been trying to create and update contact details with non ascii characters over the API and have been running into some strange problems - for example if I retrieve a contact using the GetCustomerByID method I get the following response:

    <?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
    <GetCustomerByIDResponse xmlns="KashFlow">
    <GetCustomerByIDResult>
    <CustomerID>3841499</CustomerID>
    <Code>D?PA01</Code>
    <Name>Testø</Name>
    <Contact/>
    <Telephone/>
    <Mobile/>
    <Fax/>
    <Email/>
    <Address1/>
    <Address2/>
    <Address3/>
    <Address4/>
    <Postcode/>
    <Website/>
    <EC>0</EC>
    <OutsideEC>0</OutsideEC>
    <Notes/>
    <Source>45342</Source>
    <Discount>0</Discount>
    <ShowDiscount>false</ShowDiscount>
    <PaymentTerms>0</PaymentTerms>
    <ExtraText1/>
    <ExtraText2/>
    <CheckBox1>0</CheckBox1>
    <CheckBox2>0</CheckBox2>
    <Created>2011-05-20T00:00:00</Created>
    <Updated>2011-05-20T00:00:00</Updated>
    <CurrencyID>0</CurrencyID>
    </GetCustomerByIDResult>
    <Status>OK</Status>
    <StatusDetail/>
    </GetCustomerByIDResponse>
    </soap:Body>
    </soap:Envelope>


    If I then try to update the same contact using the following UpdateCustomer method I get a 400 error - however if I remove "ø" from the name the update executes without any problem. Any suggestions?

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
    <UpdateCustomer xmlns="KashFlow">
    <UserName>the username</UserName>
    <Password>and password have been redacted to protect the innocent!</Password>
    <custr>
    <CustomerID>3841499</CustomerID>
    <Name>Testø</Name>
    <Mobile/>
    <Fax/>
    <Telephone/>
    <Email/>
    <Updated>2011-05-20T00:00:00</Updated>
    <ExtraText2/>
    <ExtraText1/>
    <EC>0</EC>
    <Code>D?PA01</Code>
    <OutsideEC>0</OutsideEC>
    <Created>2011-05-20T00:00:00</Created>
    <Discount>0</Discount>
    <CurrencyID>0</CurrencyID>
    <Contact/>
    <ShowDiscount>false</ShowDiscount>
    <Notes/>
    <Source>45342</Source>
    <PaymentTerms>0</PaymentTerms>
    <CustomerID>3841499</CustomerID>
    <CheckBox1>0</CheckBox1>
    <CheckBox2>0</CheckBox2>
    </custr>
    </UpdateCustomer>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    Regards,
    Phillip
  2. DuaneJackson Administrator

    Have you tried putting CDATA tags around the name?
  3. phillip New Member

    I've just given that a try and get the same error message - I've added a CDATA section around the content to of the name field:
    <Name><![CDATA[Testø1]]></Name>
  4. DuaneJackson Administrator

    It may simply be that it's not supported.

    It's all standard SOAP/XML

    The only other thing I can think of is to use a HTMLEncoded version of the character: ø
  5. phillip New Member

    Hi Duane,

    I think I've nutted it; Requests methods on the API appear to return the XML using UTF-8 character encoding but posting data to the API requires the XML to use ISO-8859-1 character encoding. I've since noticed that the web front end of KashFlow also runs in ISO-8859-1. So it all works sweet as long was the data you're posting ASCII characters; anything else requires the correct encoding is used.

    Regards,
    Phillip

Share This Page