Hi all,

I am trying to insert a record to an entity using esq as follows in my web service.

[OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
        ResponseFormat = WebMessageFormat.Json)]
        public string InsertCaseESQPostForSATS(DebitCardDataForSATS debitCardData)
        {
            try
            {
                var caseSchema = SystemUserConnection.EntitySchemaManager.GetInstanceByName("SBLSRM");
                var entity = caseSchema.CreateEntity(SystemUserConnection);
                entity.SetColumnValue("SBLAccountNumber", debitCardData.AccountNo);
                entity.SetColumnValue("SBLService", debitCardData.ServiceId);
                
                entity.SetDefColumnValues();
                var result = entity.Save();
                return result.ToString();
            }
            catch(Exception ex)
            {
                return ex.Message;
            }
        }

 

Column 'SBLService' is a lookup column and I am having problem while inserting a record, says, "Value 'SBLService' was not found.". I have checked and confirmed that the object has the column and is published fine. Can somebody assist me on this? How can I set value for a lookup column?

 

 

Like 0

Like

4 comments
Best reply

Roman Raj Bajracharya,

 

the value should be passed as an actual Id and also the column name shouldn't contain the . separator:

 

entity.SetColumnValue("SBLServiceId", Id here);

 

For example see this post https://community.creatio.com/questions/how-create-or-update-record-usi… where Dmytro provided an example of working with GUID columns.

 

Best regards,

Oscar

Hi,

 

Try SBLServiceId instead and also take a look in the database and check how is this column called there.

 

Best regards,

Oscar

Oscar Dylan,

Hi Oscar,

Thank you for the reply. How do I provide the value of Id of SBLService lookup? In the database, it is just 'Id' for the lookup id. I tried to access by doing SBLService.Id but it didn't help.

entity.SetColumnValue("SBLService.Id", debitCardData.ServiceId);

 

Roman Raj Bajracharya,

 

the value should be passed as an actual Id and also the column name shouldn't contain the . separator:

 

entity.SetColumnValue("SBLServiceId", Id here);

 

For example see this post https://community.creatio.com/questions/how-create-or-update-record-usi… where Dmytro provided an example of working with GUID columns.

 

Best regards,

Oscar

Oscar Dylan,

Hi Oscar,

Thank you very much. The record is now inserted. But I am having problem on the execution of a process that should occur when a record on this entity is created. This process is executing well when I create a new record from frontend(UI). Any ideas on this?

Show all comments

Hello Community,

 

The Academy guides on how to create anonymous custom configuration services using WCF / .Net Framework - https://academy.creatio.com/docs/developer/back-end_development/configuration_web_service/configuration_web_service#title-1243-3



Suppose, I have a Creatio cloud instance on Linux using .Net Core. How does one go about creating an anonymous custom configuration service??

 

Regards

Shrikanth

Like 0

Like

4 comments
Best reply

Hello Shrikanth, 



In order to enable Anonymous service for .Net Core edition of Creatio all you need to do is to add information about this service to "AnonymousRoutes" block of ..\Terrasoft.WebHost\appsettings.json file. 

It should look like this:

"Terrasoft.Configuration.[Service name]": [
    "/ServiceModel/[Service name].svc"
]

Please note that there is no need to change service's source code.

Also, in case if "System.Web" name space is being used, it has to be changed to "Terrasoft.Web.Http.Abstractions". 



Kind regards,

Roman

Hello Shrikanth,

 

To create a configuration service you need to authorize via the AuthService.svc. Please refer to the following article: https://academy.creatio.com/documents/technic-sdk/7-16/creating-configu…



Please let us know if any questions or concerns left,



Regards,

Kseniia

 

 

Kseniia Prokopenko,

The documentation clearly says that there is way to create a configuration service with Anonymous authentication. Hope you went through the Academy link I pasted in the question.



My question was - 

The documentation only lists out the steps for the WCF based configuration services (Used by .Net Framework on Windows). How does one go about creating an anonymous service on a Linux installation of Creatio using .Net Core?

Kseniia Prokopenko,

Hi Kseniia, Request and appreciate your assistance for the above query

Hello Shrikanth, 



In order to enable Anonymous service for .Net Core edition of Creatio all you need to do is to add information about this service to "AnonymousRoutes" block of ..\Terrasoft.WebHost\appsettings.json file. 

It should look like this:

"Terrasoft.Configuration.[Service name]": [
    "/ServiceModel/[Service name].svc"
]

Please note that there is no need to change service's source code.

Also, in case if "System.Web" name space is being used, it has to be changed to "Terrasoft.Web.Http.Abstractions". 



Kind regards,

Roman

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 community,

 

We've this situation where we need to send all the attachments that are linked to Documents, including the byte[] data, to a SOAP based service.

We have two solutions in order to implement this:

  1. To send the attachments we could simply convert the byte[] data to base64 string and send it within the body of the SOAP message. Some of the files are more than 10MB, so this is not the best solution.
  2. The other solution is to use the MTOM message encoder, to send the attachments in multiple parts.

We have two questions:

  1. What are the best ways to send multiple attachments through SOAP based requests?
  2. If we choose to send the attachments using MTOM, how can we implement this?

Thanks in Advance.

 

Best Regards,

Pedro Pinheiro

 

 

Like 2

Like

1 comments

Hi Pedro,

 

Maybe it's better to call the https://<instance>/0/rest/FileService/GetFile/7B332DB9-3993-4136-AC32-09353333CC7A/fileId for all the files and receive a response from the third party service? You need to call this link for each record from the DocumentFile table (filed should be modified for each time with an actual Id of a record from the DocumentFile table). Previously we didn't have such requests and we have no practical example of the logic deployment. The link above is a base link used to download attachments when clicking them on the "Attachments" detail so you can try calling it in the webservice.

 

Best regards,

Oscar

Show all comments

I am trying to configure an outbound call to a web service which requires Bearer Authentication. To authenticate, you first have to make a POST to a /token endpoint using body in application/x-form-www-urlencode format. This is a fairly common authentication scheme, but Creatio currently only supports Basic or OAuth 2.0. That's fine, I thought I'd implement the token call myself, however it appears the only content type supported is JSON. If I try to add a Body parameter, it is expecting a JSONPath. Is there some way to do this that I'm missing? Otherwise, what would it take to allow url-encoded body parameters, or add Bearer Token as a supported authentication scheme?

Like 1

Like

5 comments

Hello Aron,

 

Thank you for your question!

Please, check the screenshot below.  Token is being transferred in header: 

Please let us know if you were able to complete your business task.

 

Best regards,

Bogdan S.

I am also wondering about this.



I need to make a POST request which includes urlencodes in body.



This is the cURL of the request I'm trying to get working:

curl -X POST 'https://{server_address}/api/v2/getpersonaltoken' \
  --data-urlencode 'email={user_email}' \
  --data-urlencode 'password={user_password}'

Postman (working): https://prnt.sc/100p26e

Setup in Creatio: https://prnt.sc/100p5t4



Postman is working. But in Creatio I get this response: 

{"status":"error","message":"Email/password or login_token is missing"}

 

 

Bumping this question again

Julius,



Please use the following request parameters to get the response correctly (you need to add an "Authorization" header and two query parameters):

As a result the business process that uses the webservice with these parameters return the response correctly:

Best regards,

Oscar

Oscar Dylan,

 you are the best!

Show all comments

I have been struggling very much with handling collection type response parameters in web services.

When response parameters are or normal type they are very easy to handle in the business processes. Here we are able to handle them as parameters on the Call web service process element. And use these in the process right away.

When there is a Collection which is returned, this is very different. Now the Call web service element parameter is of type Collection of Objects with attributes.

It seems to me that this parameter-type is very difficult to handle in the business process. I can't seem to find documentation in the Academy about how to extract and loop through the contents of the Collection of Objects with attributes.

What I have found in the academy is this article about setting up the Web service.

https://academy.bpmonline.com/documents/administration/7-14/adding-resp…

What I need to learn is how to handle them in bpm'online business processes.

Is there something about this in the Academy?

Is writing source code the only option? It's difficult to debug.

Like 0

Like

6 comments

Dear Julius,

Unfortunately, it is impossible to handle parameters that have the “collection of object” type without using the source code.

Therefore, in this case we recommend using “ScriptTask” element for both calling the web-service and processing the results of call.

For more detailed assistance, please contact technical support.

Best regards,

Norton

Norton Lingard, Thank you. Is there anything like this in the academy? Because there is a special bpm'online syntax to go by in the source-code.

Dear Julius,



The service call in a "Script task” business process element can be implemented via native C#. Please find a lot of examples on how to do that in Google. For example, several links below:



https://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c



https://code-maze.com/different-ways-consume-restful-api-csharp/

Please note that it is possible to use the native C# collections instead of working with the the special bpmonline collections.

Best regards,

Norton

Hi Julius,

 

Did you manage to solve this?

 

I'm struggling with the same issue and didn't manage to get it to work.

 

Looking forward to having Your answer.

 

Raz

Norton Lingard,

Hi Norton,

 

Is there another example on how to do it in the script task?

 

I tried implementing it based on the links you posted and I'm getting many error messages when posting the code.

 

Thanks,

Raz

Dear Raz,

 

Please find another example in the article by the link below:

 

https://stackoverflow.com/questions/3900371/how-can-i-call-a-webservice-from-c-sharp-with-http-post

 

If you still can’t resolve the issue please provide us with a source code that you wrote and errors that you got.

 

Best regards,

Norton

Show all comments

Good day. I have a big task, and the last part is sending the document through a web service.

Generally speaking, I need to send not only a document, but an array of objects, among which there are documents. Documents will be in PDF format.

As I could see, the "Content type" field is protected from changes and is always JSON.

Is there any simple (or at least some) way to accomplish the task sent to me?

I have an example of performing this task in Java and there the document is loaded into the stream and then passed as an attribute ContentReference, but I do not understand how to implement this in bpm'online ..

Like 0

Like

3 comments

It's hard to understand where you want to send the document from. From bpm'online to a third party, or vise versa. If it's from bpm'online please do that via c# in a Script task in a business process. If it's vise versa, please use the same web service that we call when we add a new file to a "File" detail. Please use Fiddler in order to find the service name. 

Eugene Podkovka,

Thank you very much, I finally realized that I had to do this through C# in the Script task, but now I have another problem.

I found a code (https://stackoverflow.com/questions/17027159/how-send-a-pdf-by-post-htt…) that converts the PDF file into bytes and sends them via HttpWebRequest, but I don’t know how to get a document file.

I mean, the Server.MapPath method is used in this example, but I cannot do this. I only know that this document should be on the "Attachments and notes" tab in Contact. Is there a way to get a link to the desired document (by name, etc.) Or use the MapPath function?

I am also trying to figure out how to attach more data than just a file, because the file is just one of them. The following is the complete structure:



If you have any suggestions or tips, please, help me.

Dear Pavlo,

Please note that all documents are saved in the database in the appropriate table. For example, documents from the “Attachments and notes” tab from the Contact section are saved in the “ContactFile” table and have the object name “Contact attachment”. Therefore, it’s possible to read it like ordinary data from the database.

Please note that the column with data of the document has name “Data” and type “varbinary(max)”. In order to read data from the database please use “Read data” element of business process or use ESQ in the code of the Script task element.

Please find more detail instructions about reading and using data in the Script task element from the link below:

https://community.bpmonline.com/questions/how-read-entity-lookup-column-script-task

Best regards,

Norton

Show all comments



Hi,

If I have to build a web service from bpmonline through an api which requires the method signature to be generated by taking the query string, and creating a HMAC-SHA256 signature using your API key as the secret key.

Is there a way to do that?

There is available a sample c# code, if that helps.

Generating the method signature

    <span>private</span> <span>static</span> <span>string</span> <span>GetSignature</span><span>(</span><span>string</span> <span>args</span><span>,</span> <span>string</span> <span>privatekey</span><span>)</span> 
    <span>{</span> 
        <span>var</span> <span>encoding</span> <span>=</span> <span>new</span> <span>System</span><span>.</span><span>Text</span><span>.</span><span>UTF8Encoding</span><span>();</span> 
        <span>byte</span><span>[]</span> <span>key</span> <span>=</span> <span>encoding</span><span>.</span><span>GetBytes</span><span>(</span><span>privatekey</span><span>);</span> 
        <span>var</span> <span>myhmacsha256</span> <span>=</span> <span>new</span> <span>HMACSHA256</span><span>(</span><span>key</span><span>);</span> 
        <span>byte</span><span>[]</span> <span>hashValue</span> <span>=</span> <span>myhmacsha256</span><span>.</span><span>ComputeHash</span><span>(</span><span>encoding</span><span>.</span><span>GetBytes</span><span>(</span><span>args</span><span>));</span> 
        <span>string</span> <span>hmac64</span> <span>=</span> <span>Convert</span><span>.</span><span>ToBase64String</span><span>(</span><span>hashValue</span><span>);</span> 
        <span>myhmacsha256</span><span>.</span><span>Clear</span><span>();</span> 
        <span>return</span> <span>hmac64</span><span>;</span> 
    <span>}</span>

<span>I am trying to integrate with </span>https://apidocs.unleashedsoftware.com/AuthenticationHelp

 

Like 0

Like

1 comments

It's hard to understand what is "from bpmonline through an api". Will the service be in bpm'online or somewhere else? Should bpm'online call an external web service? 

Anyway. Please find more information about calling web services in the article by the link below.

https://academy.bpmonline.com/documents/technic-sdk/7-13/executing-odata-queries-using-fiddler

Show all comments

Hi , Can anyone help me in solving the errror while seeting up OAuth Authentication getting error in redirect Url as 

The server encountered an error processing the request. The exception message is 'Object reference not set to an instance of an object.' 

Here I am attaching the screenshot of configuration of OAuth login Page.

I am getting the exception after allowing permsission and after redirect Url . Should i need to add anything extra in redirect url or how will i get access token based on result of Redirect URL?

 

Thank You.

 

 

Like 0

Like

2 comments

Thibault Cros,

Hi, please contact our support team, we need more information to solve your problem - support@creatio.com

Show all comments

Hi,

I'm trying to create an anonymous we folllowing the guide from: 

https://academy.bpmonline.com/documents/technic-sdk/7-13/creating-anony…

The example provided is only for Verb GET and it works fine, but as soon as i change it to POST i get 403 code returned instead.

I tried changing different settings on the .config files to allow verb post but with no luck. What am i missing?

Is the system only meant to expose GET anonymous services?

Regards,

Luciano

Like 0

Like

5 comments

No. The system allows post requests. Probably you're trying to convert the GET request to the POST one. Please don't copy/paste. Write the service and the request manualy. This way you'll not make mistakes.

Hi Eugene,

Are you sure you are not talking about normal authenticated webservices?

It turns out that i had to add the svc path to DisableCsrfTokenValidationForPaths for the anonymous  in order to make it work.

Keep in mind that i need to call the POST method from outside bpm and without any authentication.

 

 

 

I'm sure. http://prntscr.com/myfefm

I tested without CSRF on localhost. 

That's not the behavior i'm seeing on my local environment. After creating the svc and registering the service on all the .config files i kept getting 403 until i enabled the path on DisableCsrfTokenValidationForPaths. Otherwise i was always getting 403.

I notice from you screenshot that you were also getting 403 before the 400 bad request,, did you change something?

 

Luciano De Munno,

Try to check how the GeneratedObjectWebFormService registered. It works with post and it seems like it doesn't require disabling CSRF.

>did you change something?

- I stoped copy-pasting and wrote the request manually from scratch. Anyway the request is on the screenshot. Please compare they on your own.

 

Show all comments