Issue with custom CRM integration

Status
Not open for further replies.

akp@2023

Free User
Joined
Jul 19, 2023
Messages
7
Reaction score
0
Hello,

We're trying to make a custom CRM integration .So I have a template and the Test button shows is working but getting this error:

"Server returned a non successful status code - HTTPStatusCode=NotFound - Reason=Not Found - Content={"status":404,"message":"No data were found"}"

Additionally, the phone number-based contact lookup gives the following result. (Getting proper result while checking in POSTMAN).

"Unexpected character encountered while parsing value: . Path '', line 0, position 0.

Started scenario with empty id
Request text: http://192.168.xx/xx/api/3cx/contacts?phone=5631XXXXXX
Response text: {"id":"123456","name":"Mr.weeqweq","phone":"5631XXXXXX","email":"[email protected]","account_number":"100000000064879","customer_id":"156497989","loan_no":"","product_type":"Ind","defaulter_type":"TELECOM","url":"http:\/\/192.168.xx.xx\/xx\/admin\/telecom_recoveries\/telecom_recovery\/1374169","type":"telecom"}
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value)
at CrmIntegration.JsonResponseParser.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(List`1 result, IEnumerable`1 scenariosToProcess, IValueManager customManager, Func`2 filterResultsFunctor, Func`1 createContactRecordFunctor, CancellationToken token)
at CrmIntegration.CrmProcessor.GetContactInfo(String contactNumber, InteractionTypes interactionType, CancellationToken token)."


My template scenario ,

<Scenarios>
<Scenario Id="" Type="REST">
<Request Url="http://192.168.xx.xx/xx/api/3cx/contacts?phone=[Number]" MessagePasses="0" RequestEncoding="UrlEncoded" RequestType="Get" ResponseType="Json" />
<Rules>
<Rule Type="Any">contact.id</Rule>
</Rules>
<Variables>
<Variable Name="ContactID" Path="contact.id">
<Filter />
</Variable>
<Variable Name="FirstName" Path="contact.name">
<Filter />
</Variable>
<Variable Name="CompanyName" Path="contact.name">
<Filter />
</Variable>
<Variable Name="Email" Path="contact.email">
<Filter />
</Variable>
<Variable Name="PhoneBusiness" Path="contact.phone">
<Filter />
</Variable>
<Variable Name="PhoneMobile" Path="contact.phone">
<Filter />
</Variable>
<Variable Name="CustomValue" Path="contact.type">
<Filter />
</Variable>
<Variable Name="ContactUrl" Path="contact.url">
<Filter />
</Variable>
</Variables>
Please help me to fix this issue.
 

Attachments

  • 3cxError.jpg
    3cxError.jpg
    87.8 KB · Views: 13
"http:\/\/192.168.xx.xx\/xx\/admin\/telecom_recoveries\/telecom_recovery\/1374169"
Why are you escaping the slash here? The forward slash (/) is not a character that needs to be escaped with a back slash. The error might be caused by that. Try returning just:
http://192.168.xx.xx/xx/admin/telecom_recoveries/telecom_recovery/1374169
 
  • Like
Reactions: jed and Evolute IT
Thanks for your reply.
I think that is not the issue. because I changed the url response to a test content. But still I got the same error.

Unexpected character encountered while parsing value: . Path '', line 0, position 0.

Started scenario with empty id
Request text: http://primxxxxx.forxxxxx.com:8085/prxxxxxxllection/api/3cx/contacts?phone=5xxxxx241
Response text: {"id":"1534931","name":"يونس عطية المسي","phone":"05xxxx1241","email":"","url":"url-for-testing"}
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at CrmIntegration.JsonResponseParser.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(List`1 result, IEnumerable`1 scenariosToProcess, IValueManager customManager, Func`2 filterResultsFunctor, Func`1 createContactRecordFunctor, CancellationToken token)
at CrmIntegration.CrmProcessor.GetContactInfo(String contactNumber, InteractionTypes interactionType, CancellationToken token)
 

Attachments

  • 3cx-url.png
    3cx-url.png
    147.2 KB · Views: 5
First of, your rule needs to be "id" as there's no object "contact" in the JSON.

Second, make sure the JSON returned is an array of object.

[{...},{...}]
 
  • Like
Reactions: edossantos
The mapping you have in your template is incorrect. The rule and also the variables. You're using contact.id, but your JSON returns just the id. The same with other variables, the path contact.XX should be replaced by XX.
 
Thanks again.
and I changed the response format as below but still the issue is not solved.

Response text: [{"contact":{"id":"1344448","name":"ajith","phone":"0502136064","email":"","url":"url-for-testing"}}]

I have attached response from postman alo
 

Attachments

  • 3cx--.png
    3cx--.png
    143.4 KB · Views: 11
  • 3cx-postman.png
    3cx-postman.png
    24.7 KB · Views: 11
Can you check if your server is returning any special character at the beginning of the response? For example, the BOM sequence at the beginning of a text file?
 
  • Like
Reactions: Evolute IT
I checked, response is fine. no special chars found in the beginning.
I inspected the response from browser developer tools. Please let me know if there is any other way I should check.
 
Can you check if your server is returning any special character at the beginning of the response? For example, the BOM sequence at the beginning of a text file?
Please help me to fix this
 
The error happens at the very beginning, so most probably it's an invisible character. You will need to check the bytes that are coming with the JSON response. If you see this from the browser console, or curl output, you will not see this, as the characters are not printable. You will need to see this from a Wireshark capture. I can see that you're using HTTP (not HTTPS) for the connection with your API, so it's easy to see it from a Wireshark capture. Just start a capture, make a test, and then check the bytes from the response. You will probably note invisible characters before the JSON starts.
 
  • Like
Reactions: Evolute IT
Could you please clarify if 'https' is required for the integration to work?
 
Could you please clarify if 'https' is required for the integration to work?
No, 3CX can connect to HTTP or HTTPS endpoints. Of course, HTTPS is recommended for security reasons, but you can still connect to an HTTP endpoint.
 
  • Like
Reactions: Evolute IT
Status
Not open for further replies.