Error in server side CRM if response from API is empty

Status
Not open for further replies.

Chris_F

Platinum Partner
Advanced Certified
Joined
Mar 21, 2019
Messages
33
Reaction score
3
Hi All,

I am currently attempting to develop a CRM integration via the integration editor.

All functions are working with the exception of popping a new contact record at the time of creation. Unfortunately our API sends a response of simply '[]' for search queries which do not return any matching contacts.

Despite setting the Matching Scenario to allow empty responses the system does not appear to be able to deal with this response and throws the following exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: source
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at CrmIntegration.ResponseMatcher.FindMatching(ResponseRepresentation obj, MatchingRule[] rules)
at CrmIntegration.ScenarioProcessorBase.FindMatchings(ProtocolScenario scenario, ResponseRepresentation response, ResponseMatcher responseMatcher)
at CrmIntegration.ScenarioProcessorBase.<ProcessScenario>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CrmIntegration.ScenarioProcessorBase.<Execute>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CrmIntegration.CrmProcessor.<CreateContactRecord>d__11.MoveNext()

Has anyone encountered this before / know a work around for this?
 
Can you share your template? I think it's an issue in your Create Contact scenario, which must return the information of the new record created.
 
Hi Ernesto, please find it attached
 

Attachments

Hello @Chris_F,

In the "CreateContactRecord" scenario, you have an empty <Rules /> element. This means that no record will be identified from the server response, and therefore no output will be generated.

You need to provide the path to the JSON node that contains something unique for a record. For example, it could be the same that you're specifying for the contact lookup scenario:
XML:
<Rules>
    <Rule Type="Number">PHONE</Rule>
</Rules>

Also, I see the following 2 outputs that are wrong:
XML:
<Output Type="ContactUrl" Passes="0" Value="https://[Insightly URL]/list/Contact/?blade=/details/contact/[CONTACT_ID]" />
<Output Type="CONTACT_ID" Passes="0" Value="[CONTACT_ID]" />

These are not correct, because there is no variable CONTACT_ID. You should map that variable first from the response, and then use it as an output.
 
Status
Not open for further replies.

Members Online Now

Forum statistics

Threads
111,832
Messages
589,282
Members
164,662
Latest member
DejanMDS