Hello Community,

 

I have a PrestaShop website to allow my important customers to simplify their hardware orders.

I am therefore in the process of developing a webservice to interface the two systems, the exchange of data being done in Json format.

 

The first feasibility tests were done in version 7.18.5 of Creatio with libraries

  • Newtonsoft.Json
  • Newtonsoft.Json.Linq
  • System.Web.Script

 

We have now moved to a new phase on a Creatio 8.0.5 and the USING of these libraries now cause problems when compiling...

 

Have you encountered this anomaly before?

Do you have examples of Json deserialization code with other libraries?

 

Thank you in advance for your help.

 

Vincent

Like 0

Like

5 comments

Greetings,



We have checked the information with our R&D team and it is as follows:

Newtonsoft.Json;

Newtonsoft.Json.Linq;

Both of these should work with no problem with the new versions of Creatio, but

System.Web.Script

Needs some adjustments from your side, since you have an on-site system.

The adjustments are as follows:

Within the file \Terrasoft.WebApp\Terrasoft.Configuration\Terrasoft.Configuration.Dev.csproj 

Within this section: <ItemGroup Label=".NET references"> 

You should add this reference <Reference Include="System.Web.Extensions" />

And correctly use the beforementioned libraries (Newtonsoft.Json; Newtonsoft.Json.Linq;) in C# schemas

Hello Mykhailo Zeleniuk,



Right now, my code is very simple (see screenshot), so I'm bothered by the compilation error...

Especially since the same code worked in version 7.18.5.

 

Someone would have examples of Json deserialization code with other libraries than Newtonsoft ?

 

Thanks

 

Vincent

 

 

LAVIGNE Vincent,

 

I did an example of a webservice that returns a JSON string result using only System; and System.Text.Json. The code is below:

namespace Terrasoft.Configuration.UsrCustomServiceNamespace
{
    using System;
	using System.Text.Json;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.ServiceModel.Activation;
    using Terrasoft.Core;
    using Terrasoft.Web.Common;
    using Terrasoft.Core.Entities;
 
 
 
	public class SerializedObject
	{
		public string FirstPart { get; set; }
		public string SecondPart { get; set; }
		public string ThirdPart { get; set; }
	}
 
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class UsrCustomService: BaseService
    {
 
		private SystemUserConnection _systemUserConnection;
        private SystemUserConnection SystemUserConnection
		{
            get
			{
                return _systemUserConnection ?? (_systemUserConnection = (SystemUserConnection)AppConnection.SystemUserConnection);
            }
        }
 
	[OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
        ResponseFormat = WebMessageFormat.Json)]
        public string ReturnCustomResult(string param1, string param2, string param3)
		{
			var objectToSerialize = new SerializedObject
            {
                FirstPart = param1,
                SecondPart = param2,
                ThirdPart = param3,
            };
			string jsonString = JsonSerializer.Serialize(objectToSerialize);
			return jsonString;
		}
	}
}

As a result calling this endpoint http://localhost:1026/0/ServiceModel/UsrCustomService.svc/ReturnCustomR… returned this result:

{"ReturnCustomResultResult":"{\"FirstPart\":\"test1\",\"SecondPart\":\"test2\",\"ThirdPart\":\"test3\"}"}

So you can this approach on your side as well.

And the test was performed in 8.0.6 full bundle application (sales + marketing + service) MS SQL.

Hello Oleg Drobina,

 

Thank you very much for your answer, I will try to adapt your example code to my case.

Indeed, I want to retrieve a JSON which is in the body of the HTTP request, so do more of a "Deserialize" request.

If you have an example of code in this way too, I am interested.

 

Thanks

 

Vincent

Show all comments

Hi Team,

We want to retrieve a specific record by Id along with all the related elements (eg - Retrieve Account A with all of its related Contacts). 

What we already know:

We can retrieve the account record itself along with related records that are linked with lookupfields, like the PrimaryContact

 

Account(0001111-1111-1111-1111-111111231123)?$expand=PrimaryContact($select=Name)

This works, but it returns only one contact, the primary one.

 

Instead, we need an embedded list of contacts, like

{
    "@odata.context": myurl.creatio.com/0/odata/$metadata#Account(PrimaryContact(Name))/$entity,
    "Id": "22222-222222-2222-222222-22222207ba6",
    "Name": "somename",
    "OwnerId": "111111-11111-11111-11111-1111111",
    "CreatedOn": "2022-11-16T21:11:57.214167Z",
    "Contacts“ : [
{object}, {object}
]
}

Given the first URL in the response, we expected that all NavigationProperties would behave the same:

But this collection:

Is not accessible. If we call for :

Account(0002204c-d255-46c0-bea6-0f32e2e07ba6)?$expand=ContactCollectionByAccount

 

We get this error in return:

{
    "error": {
        "code": "",
        "message": "An error has occurred."
    }
}

If we use other expand values, we retrieve meaningful errors like „Could not find a property named xy“, but this error is not self explaining. How can we return an object with an embedded list of children? I know that in this example we also could ask for a list of Contacts filtered by their account, but we cannot do that in all scenarios we have in mind.

Thank you

Petrika

Like 3

Like

1 comments

Hello Petrika,

 

This property cannot be used to retrieve all contacts related to the account and can be used in filtration only. To retrieve related contacts you need to perform the GET query to the Contact object with the correspondent AccountId filter. Using this approach you will be able to get contacts needed.

Show all comments

Is it possible to export an existing database schema into a creatio datamodel? Or from an ERD Data export?

 

I use lucidchart to create a model of my database, it has export functions for MySQL, PostgreSQL, SQL Server, Oracle SQL and a similar platform as creatio, Quickbase. 

 

Does creatio support such an import wizard?

Like 1

Like

1 comments

Hello Pascal,

 

unfortunately this is not quite possible.

The thing is that you can export the DB in such way, but you will not have any objects in the system.

So we would recommend sticking to the standard way. Also, we will register this option as a wish for the dev team to implement it in the future.

 

Regards,

Gleb.

Show all comments

Good day community,

 

I'm having trouble with adding the correct JSON path for my request body.

 

I have to send a POST request with the following JSON below:

{
  "members": [
    {
      "@odata.type": "--TYPE HERE--",
      "user@odata.bind": "--USER 1 HERE--"
    },
    {
      "@odata.type": "--TYPE HERE--",
      "user@odata.bind": "--USER 2 HERE--"
    }
  ]
}

This is how my parameter structure looks:

Generated JSON here:

{
	"chatType": "oneOnOne",
	"members": [
		{
			"@odata": {
				"type": "--TYPE HERE--"
			},
			"user@odata": {
				"bind": "--USER 1 HERE--"
			}
		}
	]
}

The problem with this structure is that it generates a nested key for type under @odata, and for bind as well. I don't wan't this to happen if possible.

 

Is there any way to get this to work using parameters in web service? Or would my only resort be to generate the request body via script?

Like 0

Like

2 comments

Hello,

 

The body of the webservice seems to be generated properly since "members" is the array of objects "@odata" and "user@odata". The request was properly parsed and that's why you saw the result as on the screenshot. If this structure won't work in your business case then a separate script task should be created to sent the request.

 

Best regards,

Oscar 

Hi Oscar,

 

Thank you for you response.

 

In forming the json path, I would have made it as $.[members]["@odata.dataType"] or $.[members]["user@odata.bind"], but I'm guessing that this is not possible using the built-in function (nesting parameters) in Creatio?

 

I think I'll instead be resorting to creating a script task for this.

 

Thank you!

 

Lyle

Show all comments

I'm getting a reply such as this JSON

        "company_naics_code": [
            "3271201",
            "3332491",
            "327213",
            "333249",
            "3339930",
            "3333187"
        ],

I've linked the propper array (see pictures), but the "3271201" value and so on are not saved to any parameter.

https://prnt.sc/1rli55a

https://prnt.sc/1rli5ii

How do I handle these values in the Web service method page? Surely, I need to use some nested parameter to use the retrieved vaules. But how do I format my Path to element (JSONPath) corrently when they dont have a name?

Like 1

Like

1 comments
Best reply

It's better to deserialize the JSON string directly inside the business process or the logic that you will use when calling the web service and then substruct needed values and pass them to either process parameters or use them according to your needs. Something like this in C#:

or (in case something should be performed from the client side):

If you are going to use the web-service inside the business process don't forget to add Newtonsoft.Json.Linq using in the process properties.

It's better to deserialize the JSON string directly inside the business process or the logic that you will use when calling the web service and then substruct needed values and pass them to either process parameters or use them according to your needs. Something like this in C#:

or (in case something should be performed from the client side):

If you are going to use the web-service inside the business process don't forget to add Newtonsoft.Json.Linq using in the process properties.

Show all comments

Hi Community,

 

  • I am trying to pass the JSON string into the Web-Service Element of the Business Process. I had tried this in one of the trial instances of version 7.18.0.1353. In this version, Web-Service Element has Request body parameter in its Advanced Setting. The screenshot of this is as below. 

 

 

 

  • I want to implement this same POC in another instance which is in a version of  7.17.3.1377. But the "Request body" parameter in Advanced Setting of Web-Service Element and I am not able to pass JSON in this instance.

 

 

Is there any way ? to achieve this POC working in the instance of version 7.17.3.1377

Please guide me on this.

 

Thanks and Regards.

Like 0

Like

1 comments
Best reply

Hello,

 

This feature is available starting from 7.17.4 version. The simplest way to achieve it is just to upgrade your website to 7.17.4 or even better to 7.18.0 which is the latest actual version of the app.

 

Regards,

Dean

Hello,

 

This feature is available starting from 7.17.4 version. The simplest way to achieve it is just to upgrade your website to 7.17.4 or even better to 7.18.0 which is the latest actual version of the app.

 

Regards,

Dean

Show all comments

Hello,

 

I've implemented some code because of the changes on the new version which is coming and do not support DB.Executor.

 

But when i'm executing my source code, the json result is dynamic : i've only the fields which are not empty.

In order to have a great code i've parse the json. So the format is correct that's a great json but I don't know how can I include empty field/value.

 

Is there somebody who can explain me how can I do in order to include all fields in the object to the json return list?

 

Thanks a lot.

Like 0

Like

0 comments
Show all comments

Hi all,

 

We just tried installing our package on our pre-prod environment to test and unfortunately have met an error :

 

2020-10-23 10:24:19,373 System.UnauthorizedAccessException: Access to the path '_MetaInfo.json' is denied.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)

at Terrasoft.Common.IO.FileWrapper.Create(String path)

at Terrasoft.Core.ContentGeneration.ConfigurationMetaInfoFileWriter.Write(ConfigurationMetaInfo configurationMetaInfo, String configurationMetaInfoFilePath)

at Terrasoft.Core.Packages.ConfigurationAssemblyFileStorageTransaction.UpdateConfigurationVersion(Int32 version)

at Terrasoft.Core.Packages.ConfigurationAssemblyFileStorageTransaction.Commit()

at Terrasoft.Core.Packages.WorkspaceBuilder.BuildInternalNetStandard(Boolean force, BuildResultType& buildResultType)

at Terrasoft.Core.Packages.WorkspaceBuilder.Build()

at Terrasoft.Core.AppInstallation.Packages.Operations.SystemPackageOperations.Save(IEnumerable`1 packages, PackageInstallOptions options)

at Terrasoft.Core.AppInstallation.Packages.SystemPackageManager.Save(PackageInstallOptions installOptions)

at Terrasoft.Core.AppInstallation.Packages.AppInstaller.Install(String sourcePath, String destinationPath, PackageInstallOptions installOptions, IInstalledAppInfo installedAppInfo)

at Terrasoft.Core.ServiceModelContract.PackageInstaller.AppInstallerServiceInternal.<>c__DisplayClass9_0.b__0()

at Terrasoft.Core.ServiceModelContract.PackageInstaller.BaseInstallerServiceInternal.InvokeWithLogging[TResult](Func`1 action)

 

Compilation works without errors though.

 

Any ideas how to solve this ? We are on an on-prem version.

 

Thanks and lovely day !

Like 0

Like

2 comments

Dear Amandine,

 

Usually, this error means that IIS user does not have access to all paths Creatio needs to compile the application. Try to provide full access to IIS user and check if it helps by performing full compilation. 

 

Best regards,

Angela

Angela Reyes,

Hi Angela, it was indeed a permission issue, got solved the same day :) Thanks for answering !

Show all comments

Hi,

For a few weeks I struggled with sending a HTTP POST Request to a third party application via script task.

I have a collection object that needs to be sent via the web service and eventually catch the response and use the data inside process parameters.

 

Here you can find the code for doing that using a JSON object.

 

string x_param = Get("x_process_param");

string y_param = Get("y_process_param");

string z_param = Get("z_process_param");



var ProductLines = Get>("ReadDataUserTask6.ResultCompositeObjectList");

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://url/api/v1/Documents/?token="+x_param);

httpWebRequest.ContentType = "application/json";

httpWebRequest.Method = "POST";

int ProductLineIndex = 0;

using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

using (JsonTextWriter writer = new JsonTextWriter(streamWriter))

{

    JObject InvoiceJSon = new JObject (

                            new JProperty("y",y_param),

                            new JProperty("z",z_param));

                            

    JArray JProductLinesArray = new JArray();

    foreach(var ProductLine in ProductLines) {

        

        var ProductName = "";

        decimal Qty;

        decimal UnitPrice;

        

        ProductLine.TryGetValue("Name", out ProductName);

        ProductLine.TryGetValue("Quantity", out Qty);

        ProductLine.TryGetValue("Price", out UnitPrice);

        

        JProductLinesArray.Add(new JObject(

            new JProperty("ChargeVAT","true"),

            new JProperty("Number",++ProductLineIndex),

            new JProperty("ProductName",ProductName),

            new JProperty("Qty",Qty),

            new JProperty("Rate",1),

            new JProperty("UnitPrice",UnitPrice),

            new JProperty("VATRate",17)));

    }                        

    

    InvoiceJSon.Add(new JProperty("DocumentLines",JProductLinesArray));

    

    InvoiceJSon.WriteTo(writer);

    

}



var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

{

    var result = streamReader.ReadToEnd();

    var LinkToPdf = JObject.Parse(result)["LinkToPdf"].ToString();

    var CaspitDocNum = JObject.Parse(result)["Number"].ToString();

    

    Set("DocLinkToPdf",LinkToPdf);

    Set("FinanceDocId",DocNum);

}

return true;

 

Furthermore, I attached a screenshot with the methods that I'm using in the process

 

Hope it helps.

 

Have fun :)

Good luck

 

Like 1

Like

Share

2 comments

Hi!

 

Thank you for contacting us! 

 

Could you please provide us with additional screenshots of the issue appeared to understand the case better?

 

Regards, 

Anastasiia

Anastasiia Markina,

Hi Anastasiia,



There is no issue. I struggled with this issue and I solved it.



The above code is my collaboration to the community :)

 

Hope it helps devs with the same issue.

 

Best Regards,

Raz

Show all comments

After updating creatio from ver. 7.12 to 7.15.2, when I try to change a business rule on a page i get the following error:

Has anyone found a solution for this?

Like 0

Like

2 comments

Dear Bartosz,

Most likely you've done some modifications in the business rules through the page schema. The error 'Unexpected Token in JSON' indicates that your JSON code has a syntax mistake (wrong/redundant letter, symbol, etc.) In your case this symbol is "!". You can use your browser development tools to debug the code and find the error. You can also approach the support team via support@creatio.com to investigate the update issue in your particular environment. 

Regards,

Dean

I've found the error and if I remove it, than page lets me modify business rules normaly, but why I can't add an if to a filter data business rule?

Show all comments