Having Issues with request for CRM Integration

Status
Not open for further replies.

Aaron Falzon

Silver Partner
Advanced Certified
Joined
Sep 10, 2018
Messages
20
Reaction score
2
HI,

I am trying to build an integration for a Customer's ERP / CRM.


In powershell I am able to perform a HTTP request and lookup a contact:
Fiddler shows the request like this:

1611949258536.png

However when i run the Test with the 3CX CRM Template Generator it fails.
It looks to me like the Headers are wrong but I am unsure how to fix it.
1611949482659.png

My Code:
XML:
<?xml version="1.0"?>
<Crm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Country="US" Name="SimProAPI" Version="1">
  <Number Prefix="AsIs" MaxLength="[MaxLength]" />
  <Connection MaxConcurrentRequests="2" />
  <Parameters>
    <Parameter Name="Authorization" Type="String" Parent="General Configuration" Editor="String" Title="API Key:" />
  </Parameters>
  <Authentication Type="Basic">
    <Value>[APIkey]:X</Value>
  </Authentication>
  <Scenarios>
    <Scenario Id="" Type="REST">
      <Request Url="https://XXXXXX/api/v1.0/companies/0/contacts/?columns=ID,GivenName,FamilyName,Email,CellPhone&amp;pageSize=250&amp;orderby=ID&amp;CellPhone=%25[Number]%25" MessagePasses="0" RequestEncoding="Json" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">ID</Rule>
      </Rules>
      <Variables>
        <Variable Name="ContactID" Path="ID">
          <Filter />
        </Variable>
        <Variable Name="FirstName" Path="GivenName">
          <Filter />
        </Variable>
        <Variable Name="LastName" Path="FamilyName">
          <Filter />
        </Variable>
        <Variable Name="Email" Path="Email">
          <Filter />
        </Variable>
        <Variable Name="PhoneMobile" Path="CellPhone">
          <Filter />
        </Variable>
        <Variable Name="ContactUrl" Path="url">
          <Filter />
        </Variable>
        <Variable Name="PhoneBusiness" Path="WorkPhone">
          <Filter />
        </Variable>
      </Variables>
      <Outputs Next="" AllowEmpty="false">
        <Output Type="ContactID" Passes="0" Value="[ContactID]" />
        <Output Type="FirstName" Passes="0" Value="[FirstName]" />
        <Output Type="LastName" Passes="0" Value="[LastName]" />
        <Output Type="Email" Passes="0" Value="[Email]" />
        <Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
        <Output Type="ContactUrl" Passes="0" Value="[ContactUrl]" />
      </Outputs>
    </Scenario>
  </Scenarios>
</Crm>



I should also note my programming skills are pretty basic.


Anyone got any suggestions of what to do?

Cheers.
 
Is the API using OAuth or a fixed Bearer token? Right now, it is set to Basic auth, which encodes the API Key with base64.
 
  • Like
Reactions: edossantos
What error do you get when you invoke the request from the CRM tool?
 
@Frederick Marcoux I believe its a Bearer Token. is there a way to not encode the token in the header?
I think I can try OAuth but I haven't attempted that yet

@edossantos the error i get is:


Code:
System.Exception: Server returned a non successful status code - HTTPStatusCode=Unauthorized - Reason=Unauthorized - Content=
   at CrmIntegration.ScenarioProcessorBase.ProcessRequest(ScenarioRequest request, IValueManager customManager, HttpClient client, CancellationToken token)
   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)
 
Ahhh,
So I think I worked it out.
I needed to set the authentication to none. Then add the headers to the scenario
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,324
Messages
591,897
Members
165,475
Latest member
lastshadow