Error when consuming external service.

Hi

We are currently modifying the url of a web service that is consumed from sugarcrm, the instance is an instance located in the cloud.

This is an example of the code we implemented:

curl_setopt_array($curl, array(
CURLOPT_URL => 'http://pruebas.dinissan.com.co/ClienteExternaSugarNegocio/cliente/crearOrModificarCliente',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'

{"sasa_tipo_persona_c":"N","sasa_tipo_documento_c":"C","sasa_numero_documento_c":"80084416","sasa_nombres_c":"NOMBRE 3476744 PRI APE 3476744 SEG APE 3476744","sasa_primerapellido_c":"PRI APE 3476744","sasa_last_name_2_c":"SEG APE 3476744","sasa_tipodirec1_c":"1","sasa_municipio_principal_2_c":"11001","billing_address_street":"Sin direcciu00f3n","sasa_tipodirec2_c":"1","sasa_municipio_secundario_2_c":"25126","shipping_address_street":"CRA 3E # 3E-116","sasa_tipodirec3_c":"2","sasa_municipio_3_c":"25126","sasa_direccion3_c":"CRA 3 # 3E-116","sasa_codigopostal3_c":"","sasa_cel_principal_c":"3126564877","sasa_cel_alternativo_c":"","sasa_cel_otro_c":"","sasa_tipotel1_c":"1","sasa_ciudad_tel_principal_2_c":"05021","sasa_phone_office_c":"3103459","sasa_extension_c":"","sasa_ciudad_tel_alternativ_2_c":null,"sasa_phone_alternate_c":"","sasa_extension2_c":"","sasa_tipotel2_c":"","sasa_ciudad_tel_3_c":null,"sasa_tel_phone_other_c":"","sasa_extension3_c":"","sasa_tipotel3_c":"","listEmail":[{"email_address":"caurrego@dinissan.com.co","invalid_email":"false","opt_out":"false","primary_address":"true"},{"email_address":"desarrollo@dinissan.com.co","invalid_email":"false","opt_out":"false","primary_address":"false"}],"facebook":"","twitter":"","website":"","sasa_nivel_educativo_c":"8","sasa_profesion_c":"0","sasa_ocupacion_c":"3","sasa_cargo_c":"62","sasa_ingreso_mensual_c":0,"sasa_tipo_de_vivienda_c":"1","sasa_estrato_c":"4","sasa_regimen_fiscal_c":"","sasa_estado_civil_c":"C","sasa_tiene_hijos_c":"S","sasa_numero_hijos_c":1,"birthdate":null,"sasa_edad_c":"0","sasa_genero_c":"M","sasa_cliente_fallecido_c":null,"sasa_fuente_c":"Sugar"}',
CURLOPT_HTTPHEADER => array(
'token: '.$token,
'Content-Type: application/json'
),
));


$response = curl_exec($curl);

curl_close($curl);

For some strange reason it generates error, but if consumed from postman or outside SugarCRM, this one does work.

What could be happening so that consumption within SugarCRM is not working?

Parents Reply
  • I am testing the various options. Thank you very much for the answers.
    I have tried adding this in my code, but the response is: "Empty reply from server:
    CURLOPT_SSL_SSL_VERIFYHOST => false,
    CURLOPT_SSL_VERIFYPEER => false,

    I could also try to consume the service with Guzzle as proposed by , but I get the same response: "Empty reply from server".

    The strange thing is that both codes I was able to test them on a localhost outside sugarCRM and they worked.

    Could this be a problem with the service "">pruebas.dinissan.com.co/.../crearOrModificarCliente" ?

    Regards.

Children
  • Hi

    If you can provide more details (error messages, logs, print screens) would help to understand what's going on.

    As Harald mentioned, by adding those "non-secure" CURL options should do the trick, even though is not at all recommended. 

    Our cloud instances are in a safe TLS environment, should not mix contents/protocols.

    Could you also "curl -x PUT ..." from your instance to your "pruebas.dinin..." and post here, so we can compare the headers? (if there's confidential info, you can hide or send it directly to me) once we have it figured out, I'll post it for reference.

    My gut tells me that this is a TLS/Non-Secure environment type of issue but also headers play a big part on negotiating contents and authorizations.

    SugarCRM | Principal Developer Advocate