- Joined
- Jun 19, 2019
- Messages
- 81
- Reaction score
- 87
Hi team, I've been tearing my hair out with this. I'm working on an integration with ServiceM8 which is mostly working, but I've run into a hurdle with contact creation.
I've ended up running a local service to try and deal with some limitations in the ServiceM8 API in this case, mainly that you need to create a "client" that a contact is then assigned to, so I have set this microservice to:
- Search for the name of the Company entered in the contact creation form in the Client endpoint
- Record the ID if found, otherwise create a new Client with that name and record the ID returned
- Attach the ID to a new request to the contact endpoint and create it
Where it got a bit messy is that ServiceM8 responds to POST with the UUID of the new entity in the header rather than body, but the microservice handles this as well.
I'm getting 3CX sending back an error to the user whenever this workflow is used, however I can't find anything in the logs to indicate why. My microservice is returning JSON as below:
and the scenario is as below:
Hopefully someone can see what I'm missing?
I've ended up running a local service to try and deal with some limitations in the ServiceM8 API in this case, mainly that you need to create a "client" that a contact is then assigned to, so I have set this microservice to:
- Search for the name of the Company entered in the contact creation form in the Client endpoint
- Record the ID if found, otherwise create a new Client with that name and record the ID returned
- Attach the ID to a new request to the contact endpoint and create it
Where it got a bit messy is that ServiceM8 responds to POST with the UUID of the new entity in the header rather than body, but the microservice handles this as well.
I'm getting 3CX sending back an error to the user whenever this workflow is used, however I can't find anything in the logs to indicate why. My microservice is returning JSON as below:
{ "id": "a12b1bba-d427-4923-b0e9-24024e23dc2b", "firstname": "Test", "lastname": "User", "phone": "+6421000006", "email": "", "company": "testing", "company_id": "7dc833ea-8c01-456a-b443-23fc782fa48b"}and the scenario is as below:
<Scenario Id="CreateContactRecordFromClient" Type="REST" EntityId="" EntityOrder=""> <Request SkipIf="[CreateContactEnabled]!=True" Url="http://127.0.0.1:8080/contacts" MessagePasses="0" RequestEncoding="Json" RequestType="Post" ResponseType="Json"> <Headers> <Value Key="X-API-Key">[APIKey]</Value> </Headers> <PostValues> <Value Key="firstname" SkipIf="" Passes="0" Type="String">[FirstName]</Value> <Value Key="lastname" SkipIf="" Passes="0" Type="String">[LastName]</Value> <Value Key="email" If="!=""" SkipIf="" Passes="1" Type="String">[Email]</Value> <Value Key="phone" If="[Number]!=""" SkipIf="" Passes="1" Type="String">[Number]</Value> <Value Key="company" SkipIf="" Passes="0" Type="String">[Company]</Value> </PostValues> </Request> <Rules> <Rule Type="Any">id</Rule> </Rules> <Variables> <Variable Name="Id" LookupValue="" Path="id"><Filter /></Variable> </Variables> <Outputs AllowEmpty="false"> <Output Type="ContactUrl" Passes="0" Value="https://app.servicem8.com/clients/[Id]" /> <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="[Number]" /> <Output Type="EntityId" Passes="0" Value="[Id]" /> <Output Type="EntityType" Passes="0" Value="Contacts" /> </Outputs> </Scenario>Hopefully someone can see what I'm missing?
Last edited: