Is it possible to read response headers?

Status
Not open for further replies.

RuslanKhasanov

Joined
Aug 29, 2018
Messages
10
Reaction score
0
Hello,
I am trying to integrate 3CX with CRM (BPMOnline) using 3CX Template Generator tool and encountered with a problem - Template generator tool did not allow to specify HTML headers. But in one of the threads i saw that request headers may be specified directly in xml file by hand. Is it possible some way to read response headers? It is important for me because CRM returns some security information in HTML headers.
 
You can add headers to the HTTP request, but not read them from the response.
 
Thank you for reply. We have programmed custom http filter that complements response with security tokens. And I continue to implement my template and have no success. There is a single authentication scenario in my template and when I run it, i see nothing in response ("Request/Respose", "Response tree", "Variables", "Output" tabs are empty). What I am doing wrong? What is necessary to get response?
I also tried to get json object from https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json and parse it, but tool crashes with System.NullReferenceException in CrmIntegrationTool.ViewModel.Debug.ParameterValuesView.RefreshValues() while trying run template.
 
Last edited:
Can you share some screenshots? The error you get, the configuration you provide, that will help us to understand what's going on and give you some guidance...
 
I have restarted application and System.NullReferenceException exception gone. But still nothing in response window. This is my simple template, I just try to understand how to work with tool:
Code:
<?xml version="1.0"?>
<Crm xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Country="RU" Name="BPMOnline" Version="1">
  <Number Prefix="AsIs" MaxLength="" />
  <Connection MaxConcurrentRequests="2" />
  <Authentication Type="No">
    <Value>auth</Value>
  </Authentication>
  <Scenarios>
    <Scenario Id="myScen">
      <Request SkipIf="" Url="https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json" Message="" RequestType="Get" ResponseType="Json" />
      <Rules>
        <Rule Type="Any">squadName</Rule>
      </Rules>
      <Variables>
        <Variable Name="message" Path="squadName" />
      </Variables>
      <Outputs Next="" AllowEmpty="false">
        <Output Type="Bearer" Value="threeCX" />
      </Outputs>
    </Scenario>
  </Scenarios>
</Crm>
 
2 issues here:
1) The scenario ID must be empty. This way the scenario is considered for contact lookup.
2) Add at least 1 parameter. This seems to be a bug when there are no parameters defined. So add 1 parameter, even if you don't use it.

After doing that, you can run a test lookup, I have done it here and it works fine.
 
Thank you. It is really working. Now i can to examine other things. And will try our CRM authentication mechanism.
 
I have just added a request body like this {"UserName": "", "UserPassword": ""} and another error popped up:
Code:
<p>The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is: </p>
      <p>   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>
Help me, please, what to do?
 
This is because you need to specify the Content Type for the request. This is not available through the tool yet, we'll be providing a new updated tool in a few days including all the missing features for v16. Meanwhile, you will need to edit the XML, and provide the attribute:
RequestContentType="application/json"
 
Thank you, Ernesto!
 
Sorry, the attribute is for the Request element.
 
I can't understand how tool works with edited by hand template. There is still error:
Code:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Path '', line 0, position 0.
   в Newtonsoft.Json.JsonTextReader.ParseValue()
I will wait for updated tool then.
 
You can test this from the 3CX Console > Settings > CRM integration > Server side tab. There is a Test button, and you can emulate a caller number lookup from there.
 
Thank you Ernesto for support!
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,323
Messages
591,896
Members
165,474
Latest member
costionofrei