Solved CRM API to ERP system, XML error on response

Status
Not open for further replies.

ckrammer

Premier Customer
Joined
Dec 3, 2020
Messages
42
Reaction score
42
Hello everybody,

I am trying to connect 3CX to my ERP system to get customer information for incoming calls. I used the CRM API wizard to generate the attached XML and imported it. When I fill the base URL parameter and test the connection, I get the following message:

Code:
Data at the root level is invalid. Line 1, position 1.

Code:
Started scenario with empty id
Request text: http://b75.xxxx.de:8100/xxxxx/callin/3cx/search/1234567890
Response text: {
  "id": "508986-0@1",
  "firstname": "",
  "lastname": "",
  "company": "Christoph Krammer",
  "phone": "+49 1234 567890",
  "mobile": "+49 111 0000000"
}
System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
   at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
   at CrmIntegration.XmlResponseParser.Parse(String responseText)
   at CrmIntegration.ScenarioProcessorBase.ProcessScenario(ProtocolScenario scenario, IValueManager customManager, CancellationToken token)
   at CrmIntegration.ScenarioProcessorBase.Execute(ProtocolScenario scenario, CancellationToken token)
   at CrmIntegration.CrmProcessor.GetContactInfoFromCrm(String contactNumber, Boolean isInboundCall, String destinationEmail, Boolean createIfNotFound, CancellationToken token)

When I open the request URL from above in my browser, I get the following result:

Code:
<?xml version='1.0' encoding='UTF-8'?>
<PbxContact>
  <id>508986-0@1</id>
  <firstname />
  <lastname />
  <company>Christoph Krammer</company>
  <phone>+49 1234 567890</phone>
  <mobile>+49 111 0000000</mobile>
</PbxContact>

I don't see the error here, what is going wrong?

Regards,
Christoph
 

Attachments

The server is returning JSON and not XML. You should change the attribute ResponseType="Xml", or change the request, passing some parameter that forces that the response is XML instead of JSON.
 
No, the result is XML, I posted what I get when I open the request URL in my browser.

Nevertheless, when I change the ResponseType to Json, I get the very same error as above.
 
From your log:
Request text: http://b75.xxxx.de:8100/xxxxx/callin/3cx/search/1234567890
Response text: {
"id": "508986-0@1",
"firstname": "",
"lastname": "",
"company": "Christoph Krammer",
"phone": "+49 1234 567890",
"mobile": "+49 111 0000000"
}


The response is JSON and not XML.

The path in this JSON is different, because you don't have the "PbxContact" node.
 
  • Like
Reactions: Evolute IT
Sorry, I got really confused as my browser shows the same response as XML. I really don't know why this is happening, but when I change the CRM template to JSON and adjust the paths, the test is successful.

Thanks alot.
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Forum statistics

Threads
112,323
Messages
591,891
Members
165,470
Latest member
Robert Lee