Search code examples
phpxmlebay-api

Correct symbols in XML eBay API request


I am trying to get a product through eBay API using this XML request:

<aspectFilter>
    <aspectName>Genre</aspectName>
    <aspectValueName>Comedy & Spoken Word</aspectValueName>
</aspectFilter>

But I receive following error in response:

<errorMessage xmlns="http://www.ebay.com/marketplace/search/v1/services">
   <error>
      <errorId>2030</errorId>
      <domain>CoreRuntime</domain>
      <severity>Error</severity>
      <category>System</category>
      <message>Internal error: [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) (missing name?)
         at javax.xml.stream.SerializableLocation@1b0a1b0a</message>
      <subdomain>System</subdomain>
      <parameter name="Param1">[com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) (missing name?)
         at javax.xml.stream.SerializableLocation@1b0a1b0a</parameter>
   </error>
</errorMessage>

Could anyone tell me what I am doing wrong?


Solution

  • This is because of the special character & which is causing the error. eBay system doesn't accept special character as inpit so you should convert to html code, so & should be passed as &#38;. Then your request should look like this

    <aspectFilter>
        <aspectName>Genre</aspectName>
        <aspectValueName>Comedy &#38; Spoken Word</aspectValueName>
    </aspectFilter>