Hi everyone,

I’m working on a custom web service and tried integrating Npgsql. After encountering a "no namespace found" error, I took the following steps:

  1. Added the Npgsql.dll file to the Tearsoft.web/bin directory.
  2. Modified the web.config file with the following binding redirect:

    xml
     

  3. <dependentAssembly>
        <assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.5.0" newVersion="8.0.5.0" />
    </dependentAssembly>
  4. Restarted the IIS server.
  5. Flushed Redis via the Clio CLI.

After these steps, I'm now facing the following error: Could not load file or assembly 'System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (Screenshot attached for reference)

I've already checked assembly binding logging, but I’m unsure how to resolve this error. Any suggestions or help would be appreciated!
 

Additional Context:

  • Working with PostgreSQL using Npgsql in the custom web service.
  • I made changes to the web.config file after adding the Npgsql DLL.


    this is the current state for my local instance .
     

Thanks in advance!

Like 0

Like

1 comments

Hi,

This issue requires a deeper analysis, and we advise you to create a case for Creatio support.

Thank you!

Show all comments

Hi Creatio Community,

I am working on extending the existing implementation of the Execute method in the web service designer, which is part of a base package in Creatio. My goal is to modify the method to add additional functionality: specifically, I want to save the web service response as a record using an EntitySchemaQuery (ESQ), so that the response can be displayed in a custom section inside Creatio.

However, I am encountering a compilation error:

Error:
cannot convert from 'System.Collections.Generic.IEnumerable<Terrasoft.Configuration.ServiceSchemaParameter>' to 'System.Collections.Generic.IEnumerable<Terrasoft.Configuration.ServiceSchema.ServiceSchemaParameter>'

It appears that the system is having difficulty converting between two types that have the same name but are possibly from different namespaces. I am using ServiceSchemaParameter in my custom implementation, but the IServiceSchemaClient.Execute() method is expecting the parameter to be of a slightly different type.

Here’s an overview of my approach:

  1. I've modified the Execute method to include an ESQ that logs the web service call and stores the response.
  2. The issue arises when passing the parameters (of type List<ServiceSchemaParameter>) to the Execute method, where it's expecting IEnumerable<ServiceSchema.ServiceSchemaParameter>.
  3. I believe the conflict is due to namespace ambiguity or mismatched types between base and custom implementations.

    My code: 
     
  4. namespace Terrasoft.Configuration
    {
     
     
        using System;
        using System.Linq;
        using System.Collections.Generic;
        using System.Runtime.Serialization;
        using System.ServiceModel;
        using System.ServiceModel.Web;
        using System.ServiceModel.Activation;
        using Terrasoft.Core.Factories;
        using Terrasoft.Services;
        using Terrasoft.Web.Common;
        using Terrasoft.Core;
        using Terrasoft.Core.Entities;
        using Terrasoft.Configuration.ServiceSchema;
     
    	#region Class: CallServiceSchemaService
     
    	[ServiceContract]
    	[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    	public class CallServiceSchemaService : BaseService
    	{
    		#region Methods: Public
     
    		[OperationContract]
    		[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
    			ResponseFormat = WebMessageFormat.Json)]
    		public CallServiceSchemaResponse Execute(string serviceName, string methodName, List<ServiceSchemaParameter> parameters) {
    			if (parameters == null) {
    				parameters = new List<ServiceSchemaParameter>();
    			}
    			try {
    				UserConnection.DBSecurityEngine.CheckCanExecuteOperation("CanManageSolution");
     
    				// Getting the builder and client from the ClassFactory
    				var builder = ClassFactory.Get<IServiceSchemaParameterBuilder>();
    				var serviceSchemaClient = ClassFactory.Get<IServiceSchemaClient>();
     
    				// No need to cast, List<T> already implements IEnumerable<T>
    				var serviceResponse = serviceSchemaClient.Execute(UserConnection, serviceName, methodName, builder.Build(parameters.AsEnumerable()));
     
    				// Log the request and response
    				LogWebServiceCall(serviceName, methodName, parameters, serviceResponse);
     
    				return new CallServiceSchemaResponse(serviceResponse);
    			} catch (Exception e) {
    				return new CallServiceSchemaResponse(e);
    			}
    		}
     
    		#endregion
     
    		private void LogWebServiceCall(string serviceName, string methodName, List<ServiceSchemaParameter> parameters,
                IServiceClientResponse response = null, Exception error = null) {
                var entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("UsrWebServiceLog");
                var assignersEntity = entitySchema.CreateEntity(UserConnection);
                assignersEntity.SetDefColumnValues();
     
                assignersEntity.SetColumnValue("UsrServiceName", serviceName);
                assignersEntity.SetColumnValue("UsrMethodName", methodName);
                // Log additional columns if needed, as seen in your commented code
                assignersEntity.Save();
            }
     
    	}
     
    	#endregion
     
    	#region Class: CallServiceSchemaResponse
     
    	[DataContract(Name = "CallServiceSchemaResponse")]
    	public class CallServiceSchemaResponse : ConfigurationServiceResponse
    	{
    		#region Constructor: public
     
    		public CallServiceSchemaResponse(IServiceClientResponse serviceResponse) {
    			StatusCode = serviceResponse.StatusCode;
    			Success = serviceResponse.Success;
    			ResponseBody = serviceResponse.Body;
    			ResponseRawData = serviceResponse.RawDataResponse;
    			RequestBody = serviceResponse.RequestBody;
    			RequestRawData = serviceResponse.RawDataRequest;
    			ParameterValues = Newtonsoft.Json.JsonConvert.SerializeObject(serviceResponse.ParameterValues);
    		}
     
    		public CallServiceSchemaResponse(Exception e) : base(e) {}
     
    		#endregion
     
    		#region Properties: Public
     
    		[DataMember]
    		public int StatusCode;
     
    		[DataMember]
    		public string ParameterValues;
     
    		[DataMember]
    		public string RequestRawData;
     
    		[DataMember]
    		public string RequestBody;
     
    		[DataMember]
    		public string ResponseRawData;
     
    		[DataMember]
    		public string ResponseBody;
     
    		#endregion
    	}
     
    	#endregion
     
    	#region Class: ServiceSchemaParameter
     
    	[DataContract]
    	public class ServiceSchemaParameter
    	{
    		#region Properties: Internal
     
    		[DataMember(Name = "code")]
    		public string Code;
     
    		[DataMember(Name = "value")]
    		public object Value;
     
    		[DataMember(Name = "nested")]
    		public List<List<ServiceSchemaParameter>> NestedParameters;
     
    		#endregion
    	}
     
    	#endregion
    }

 

Request:
Could anyone guide me on how to properly resolve this type conversion issue? If there is a better way to manage the namespace or cast the types correctly, I would appreciate any advice or best practices to ensure compatibility between the types.

Thank you for your help!

Code Context:
CallServiceSchemaService.svc 
Service Designer Package

Looking forward to your suggestions and insights!

Like 2

Like

1 comments

Hello Pranshu Basak,

Please change the part of the code 

var serviceResponse = serviceSchemaClient.Execute(UserConnection, serviceName, methodName, builder.Build(parameters.AsEnumerable()));

to the new one:

var serviceResponse = serviceSchemaClient.Execute(UserConnection, serviceName, methodName, builder.Build((IEnumerable&lt;ServiceSchema.ServiceSchemaParameter&gt;)parameters.AsEnumerable()));

for solving the compilation error.

 

Show all comments

Hello. 

 

I'm doing an Web services to send a document to sign, the api request the Url of the document so I'm using the following link https:[creatio instance]/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875

 

70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a correspons to the  UId from the SysSchema table where the attachments are stored and the ef68e95e-ef77-eddf-dfa8-685557ee4875 is the Id of the attachment. This URL allows me to dowloand the document to my computer, so I know that is the right link but when I used it in the web service it says that there is no document. 

 

The json of the request is the following 

{
 
    "url_doc": {
 
        "url": "https://151929-crm-bundle.creatio.com/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875",
 
        "name": "Contrato.pdf"
 
    },
 
    "stickers": [
 
        {
 
            "authority": "Vinculada a Correo Electronico por Liga",
 
            "stickerType": "line",
 
            "dataType": "email",
 
            "email":"laura@artica.digital",
 
            "data": "laura@artica.digital",
 
            "imageType": "stroke",
 
            "page": 0,
 
            "rect": {
 
                "lx":74.88173,
 
               "ly":312.32596,
 
               "tx":196.9875,
 
               "ty":373.37885
 
            }
 
        }
 
    ]
 
}

 

When I sent the request the response is 

 

{
    "error": "No document"
}

 

I had try this request with a Dropbox URL and works fine but I need to send the documents that are generated by the Word Reports. That why I'm trying to get the document from Creatio using the URL the API also gives me the option of sending the document using base64 but I dont know how to convert the file easly. 

 

Can you help me please to know what is happenig? 

Thank you

Like 0

Like

4 comments

The reason why this isn't working is because FileService/GetFile requires authentication to read. This is not an anonymous endpoint. The receiver of this, where ever you're sending this URL of the document to, is actually getting a 401 Unauthorized. 

You'd have to either go the route of sending the base64 of the file, or expose an anonymous service in Creatio to provide the file to the other service.

Ryan

Ryan Farley,

Thank you, can you explain me please how can I convert the file to base64 please, I had see some examples but I not sure if I can do it using a script task in a business process or a source code 

Laura Jurado,

The code would look something like this (not tested, but this should get you started). For this, I have two process params, one a uniqueidentifier AccountFileId (an Id of an account file) and second an unlimited text AccountFileBase64. The script task would look something like this:

var fileId = Get&lt;Guid&gt;("AccountFileId");
 
var entity = UserConnection.EntitySchemaManager.GetInstanceByName("AccountFile").CreateEntity(UserConnection);
if (entity.FetchFromDB(fileId))
{
    var base64FileData = Convert.ToBase64String(entity.GetBytesValue("Data"));
    Set("AccountFileBase64", base64FileData);
}

Ryan

Ryan Farley,

Thank you very much. It helped me a lot 

Show all comments

I am connecting a third-party API to Creatio, it delivers different types of data including this:
"user_id": [
60,
"Luismary Mendez"
]
In the parameters of the Creatio response I have set it as an Array Text and as an Object

 

But when I try to connect this variable to the process it does not display it in the list of possible result values.

The field is Vendedor:

Like 0

Like

5 comments

This is because the user_id is an array in the payload received from the web service, not just a single value. If you know the array will only contain a single set of values and the first value in the user_id array will always be the integer Id and the second value will always be the text name, you could flatten them out by mapping them as text and integer values:

  • Map ID as: user_id[0]
  • Map Name as: user_id[1]

Ryan

Ryan Farley,

What you're telling me is that I have to set the user_id as an object?

You could, but that doesn't pass to a subprocess (with an array inside an array). If you are able to flatten it out and if you know the array will only contain a single set of values and the first value in the user_id array will always be the integer Id and the second value will always be the text name, that will pass easily to a subprocess. Like this for the "user_id" first element in array, which is an int from what you've shared:

The second value in the user_id array, which is a string from what you've shared, would look like this:

This is assuming your JSON looks like this:

{
	"result": [
		{
			"id": "someid",
			"name": "somename",
			"user_id": [
				60,
				"Some name"
			]
		}
	]
}

You're basically changing it from an array with an int in index 0 and string in index 1 to flattened out properties pointing to the value in index 0 and index 1. This is, of course, assuming that the user_id array will only contain an int at index 0 and a string at index 1.

Ryan

Ryan Farley,

Thanks Ryan, I understood your explanation, I will apply it and let you know how it goes.

Carlos Soto,

Thanks Ryan. It's works

Show all comments

Hello.

I have a web services API that requires an Id and an hmac generated with the request parameters and an API Key to be placed in its authorization header.

Is there a way to obtain the call body to perform the HMAC?

In postman I have been able to make the call successfully with a pre-request which is the following:

 

const apiKey = pm.collectionVariables.get("apiKey");;
const webId = pm.collectionVariables.get("webId");
const crypto = require('crypto-js');
 
if(pm.request.method === 'POST') {
 
    const parsedBody = JSON.parse(pm.request.body.raw);
    const jsonParams = JSON.stringify(parsedBody);
 
    // Create HMAC
 
    const hmac = crypto.HmacSHA256(jsonParams, apiKey);
    const hmacb64 = crypto.enc.Base64.stringify(hmac);
 
    // Set computed HMAC as an environment variable (or you could add it directly to the headers)
    pm.environment.set('hmacb64', hmacb64);
 
    // Construct the Authorization header
    const authorizationHeader = "signmage " + webId + ":" + hmacb64;
    pm.environment.set('Authorization', authorizationHeader);
} else if(pm.request.method === 'GET') {
 
    const url = pm.request.url.getPathWithQuery();
 
    const hmac = crypto.HmacSHA256(url, apiKey);
    const hmacb64 = crypto.enc.Base64.stringify(hmac);
 
    // Set computed HMAC as an environment variable (or you could add it directly to the headers)
    pm.environment.set('hmacb64', hmacb64);
 
    // Construct the Authorization header
    const authorizationHeader = "signmage " + webId + ":" + hmacb64;
    pm.environment.set('Authorization', authorizationHeader);
}

 


But in Creatio I'm a little lost if it's possible to do something similar.

I would appreciate it if you could help me know if this is possible. Thank you.

Like 1

Like

1 comments

Hello Laura,

Thank you for your question.

I have contacted our R&D team regarding when this functionality will be implemented in our system. The HMAC-SHA256 signature is planned to be implemented with the 8.3 release. Currently, there is no built-in API to use HMAC.

Hope this helps.

Show all comments

I have integrated SOAP service in trial version of Sales Creatio. The test request was successful and returns the response parameters correctly, but when I'm trying to call the webservice in business process and bind the response parameter to auto-generated page, it shown only "Response body" in Process Elements parameter.

 

Please, refer the screenshots attached.

 

 

 

Any guidance would be appreciated!

Like 0

Like

3 comments

My guess is that it is because the web service is returning an array of records and the MemberNumber is from an element in the array/collection. If the web service is really just returning one record, but wrapping it in an array, you could map the field in the web services setup in Creatio as something like (you might need to modify this to match the structure of the json returned from the API):

$.[0].MemberNumber

To specifically get the value from the record at index 0 of the array.

Ryan

How to bind all the records from array/collection in grid from web service response without entity?

Revathi,

You’ll need to use a subprocess and pass each item returned to the sub process. See an article on that here https://customerfx.com/article/working-with-collections-from-a-web-service-element-in-a-process-in-creatio/

Ryan

Show all comments

Hello Community,

 

When calling a custom web service that uses anonymous authentication from the browser using this link : 

"http://mycreatio.com/0/ServiceModel/UsrCustomConfigurationService.svc/G…"

 

The page does not seem to work.

 

Note :  we have an on premise Creatio instance on Linux based on .Net Core.

 

Bellow are the steps to reproduce the case:

 

The Academy guides on how to Create a custom web service that uses anonymous authentication for .NET Core : https://academy.creatio.com/docs/developer/back_end_development/web_ser…

This is the class indicated in the first step (that returns the contact ID by the contact name) : 

namespace Terrasoft.Configuration.KycCustomConfigurationService {

    using System;

    using System.ServiceModel;

    using System.ServiceModel.Web;

    using System.ServiceModel.Activation;

    using Terrasoft.Core;

    using Terrasoft.Web.Common;

    using Terrasoft.Core.Entities;

    using Terrasoft.Web.Http.Abstractions;

    [ServiceContract]

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

    public class KycCustomConfigurationService: BaseService {

        private SystemUserConnection _systemUserConnection;

        private SystemUserConnection SystemUserConnection {

            get {

                return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection) AppConnection.SystemUserConnection);

            }

        }

        /* The method that returns the contact ID by the contact name. */

        [OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

            ResponseFormat = WebMessageFormat.Json)]

        public string GetContactIdByName(string Name) {

            SessionHelper.SpecifyWebOperationIdentity(HttpContextAccessor.GetInstance(), SystemUserConnection.CurrentUser);

            var result = "";

            var esq = new EntitySchemaQuery(SystemUserConnection.EntitySchemaManager, "Contact");

            var colId = esq.AddColumn("Id");

            var colName = esq.AddColumn("Name");

            var esqFilter = esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Name", Name);

            esq.Filters.Add(esqFilter);

            var entities = esq.GetEntityCollection(SystemUserConnection);

            if (entities.Count > 0) {

                result = entities[0].GetColumnValue(colId.Name).ToString();

                result = entities[0].GetTypedColumnValue(colId.Name); */

            }

            return result;

        }

    }

}

and this is the changes to the ..\Terrasoft.WebHost\appsettings.json file

"Terrasoft.Configuration.KycCustomConfigurationService": [

                                "/ServiceModel/KycCustomConfigurationService.svc"

                        ]



Thank you,

 

Like 0

Like

1 comments

Hello,
Based on the coe alone it is almost impossible to say what is the cause of the issue.
What kind of error you are facing, why do you think that the page isn't working?
Make sure that you created a class in the ..\Terrasoft.WebApp\ServiceModel for your service and check if you modified a services.config files as well as the Web.config.

Show all comments

In a Business Process, we are calling a Web Service using the Web Service Call element, but sometimes we will get a failure that we need to log to a custom table for action later. We really could do with as much information about the failure as possible, including being able to log out the parameters that the Web Service was passed so the support users can assess what happened without having to have trace logging turned on for the BP and digging into the BP log as well. I can't see any output on the web service call for that, but maybe someone else has found a way to get this info?

Like 2

Like

2 comments

Hi Harvey, we have similar needs, but no result, unfortunately. 

So, we log all parameters manualy before calling web service :(

Hello Harvey,



If you want to see the body of the request generated by the web service and the response that comes from the server - You can try to use Telerik Fiddler tool to capture requests that are being sent from the Creatio instance

 

But this advice is relevant only for local environments.

If the environment is on a local machine, you can connect Fiddler and test it.

 

In general, if you do not want to use data tracing for a process, we believe that this goal can be achieved through development. For example, a web service call will be made using a script task, in which you will process various responses from the server and write the information you need into a table using C# code.



Thank you.

Show all comments

Hello,

 

we use Web service element in our business process, where we set several parameters. For logging purposes we need to get JSON of request body, but there is no such option (I see only Response body)



How can we get request body from the Web service element?



Thanks.

Vladimir

Like 0

Like

3 comments

Hello,

Unfortunately, Web service element doesn't directly expose the request body for logging within the element itself. 

 

Hello, 

 

and no hidden workaround? Or any methods, which are used from request body generation, that we could use as well?



Kind regards,

Vladimir

Hello Vladimir,



You can try to use Telerik Fiddler tool to capture requests that are being sent.

Show all comments
Hello. 
Hello.

I need to send an image through an API to convert it to base 64, I tried to do it using the Web service tool but it does not allow me to place an image or file field to use it from the bpm, I was looking for some information and I saw that it could be done using a script, I just haven't found a way to do it. Could you help me with some example or idea so I can do this please?

 

 

 

Like 0

Like

1 comments

Hello Laura, 

 

Please refer to this article for more detailed information about such functionality.  

Also, similar questions have already been discussed in the below posts, please review them for the detailed information:

https://community.creatio.com/questions/there-option-send-image-file-re…

https://community.creatio.com/questions/file-type-request-parameter-res…

Please inform us in case of any questions!

Best regards,

Anastasiia

Show all comments