Jump to content

Resco CRM Connector: Difference between revisions

From Resco's Wiki
Methods: add ExportProject and ImportProject
 
(66 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Integration TOC}}
{{Integration TOC}}
[[Resco Cloud]] server can serve as a stand-alone backend, but it can also connect to other CRM or ERP systems, for example Microsoft Dynamics or Salesforce.
Resco CRM connector is a group of web API services that you can use to connect your third-party backend to [[Resco Cloud]] to exchange data between the systems. These are the components involved in Resco CRM Connector.


[[File:Crm integration.png]]
[[File:Resco crm connector.png|alt=Resco crm connector architecture|600px]]


* Your system: any CRM/ERP system
* Your system: any CRM/ERP system
* Resco CRM connector: Synchronization module between ERP System and Resco CRM Server
* [[Resco CRM Connector]]: Synchronization module between your backend and Resco Cloud
* Resco CRM server: Fully customizable backend for Mobile CRM Client application
* [[Resco Cloud]]: Fully customizable backend for Resco mobile apps
* Resco CRM client: End-user CRM application customized for Resco CRM server
* [[Resco mobile apps]]: Any of the end-user applications customized for Resco Cloud, such as [[Resco Mobile CRM]]


Resco CRM server and client are provided by Resco. Resco CRM server allows you to define schema and stores data for Mobile CRM Client, which is used to display the data.
Resco Cloud and mobile apps are provided by Resco. Resco Cloud allows you to define schema and stores data for mobile apps, which is used to display the data.


You can now build your own Resco CRM Connector to enable the synchronization between your backend system and the Resco CRM Server. Resco CRM Server acts like a passive module — it does not initiate any synchronization. Mobile CRM Client must initiate the synchronization process to download/upload data. This also applies for Resco CRM Connector. It must determine when/whether to synchronize ERP System data with data stored on the Resco CRM Server. For example, every hour, every day, etc., depends on how current the data must be on the clients. To check whether there are new/updated data on the Resco CRM Server use “GetMaxRowVersion” web service method to get the current row version. If the current row version changed from the last stored row version, there are new changes available on the Resco CRM Server.
You can now build your own Resco CRM Connector to enable the synchronization between your backend system and the Resco Cloud. Resco Cloud acts as a passive module — it does not initiate any synchronization. Mobile apps must initiate the synchronization process to download/upload data. This also applies to Resco CRM Connector. It must determine when/whether to synchronize ERP system data with data stored on the Resco Cloud. For example, every hour, every day, etc., depends on how current the data must be on the clients. To check whether there are new/updated data on the Resco Cloud use “GetMaxRowVersion” web service method to get the current row version. If the current row version changed from the last stored row version, there are new changes available on the Resco Cloud.


Resco CRM Connector consists of a set of REST web service methods divided into '''metadata service''' and '''data service'''.
== Available APIs ==
 
Resco CRM Connector offers multiple APIs:
* REST data service - a set of REST web service methods divided into '''metadata service''' and '''data service'''
* [[OData service]]
* [[Questionnaire OData service]] - read-only [https://www.odata.org/ OData v4] API service for accessing questionnaire results
* [https://www.nuget.org/packages/Resco.Cloud.Client Resco Cloud Client web services API]
 
This article describes the REST data service.


== Data types ==
== Data types ==
Line 30: Line 38:
* RowVersion
* RowVersion
* PartyList
* PartyList
By default, the data type format in data service requests and responses is in invariant culture (for example, the decimal separator is always a dot).
Date fields are in UTC time, in the following format: <code>yyyy-MM-ddTHH:mm:ssZ</code>; for example, <code>2020-12-12T09:00:00</code>. Optionally, you can use syntax defined in [https://www.ietf.org/rfc/rfc3339.txt RFC 3339] to modify this format.
Lookup fields are essentially strings in the following formats:
* <code>entity:id</code> (for create/update requests)
* <code>entity:id:name</code> (for fetch requests)
PartyList fields use the following format (parts in square brackets are optional):
<syntaxhighlight lang="xml>
<party [addressused='rajesh@example.com']>entity:id[:name]</party>
<party [addressused='howard@example.com']>entity:id[:name]</party>
...
</syntaxhighlight>


== Data service ==
== Data service ==
Line 35: Line 59:
Data service helps you access and manipulate data on Resco CRM server. The web service URL depends on server settings; whether the server uses domain organization selection or simple URL organization selection.
Data service helps you access and manipulate data on Resco CRM server. The web service URL depends on server settings; whether the server uses domain organization selection or simple URL organization selection.


* URL organization base web service URL is: <code>https://example.com/rest/v1/data/{organization}</code>
* URL organization base web service URL is: <code><nowiki>https://example.com/rest/v1/data/{organization}</nowiki></code>
* Domain organization base web service URL is: <code>https://{organization}.example.com/rest/v1/data</code>
* Domain organization base web service URL is: <code><nowiki>https://{organization}.example.com/rest/v1/data</nowiki></code>
* Resco Cloud server uses the following domain organization selection: <code>https://{organization}.rescocrm.com/rest/v1/data</code>
 
* Resco Inspections cloud server uses the following domain organization selection: <code>https://inspections.resco.net/rest/v1/data/{organization}</code>
;Examples
* Resco Cloud server uses the following domain organization selection: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data</nowiki></code>
* Resco Inspections cloud server uses the following domain organization selection: <code><nowiki>https://inspections.resco.net/rest/v1/data/{organization}</nowiki></code>
* Resco Routes cloud server uses the following domain organization selection: <code><nowiki>https://routes.resco.net/rest/v1/data/{organization}</nowiki></code>


=== Web request requirements ===
=== Web request requirements ===
Line 79: Line 106:
|-
|-
| POST || ImportProject
| POST || ImportProject
|-
| POST || GenerateReport
|-
| POST || ExecuteWorkflow
|}
|}


Line 87: Line 118:
No parameters.
No parameters.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data/WhoAmI</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/WhoAmI</nowiki></code>


Response:
Response:
Line 105: Line 136:
No parameters.
No parameters.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data/GetMaxRowVersion</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/GetMaxRowVersion</nowiki></code>


Response:
Response:
Line 112: Line 143:
<?xml version=“1.0” encoding=“utf-8“?>
<?xml version=“1.0” encoding=“utf-8“?>
<string>3665</string>
<string>3665</string>
</syntaxhighlight>
=== POST GetRecordCount ===
Get the number of entity records.
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/GetRecordCount</nowiki></code>
Examples of body requests:
<syntaxhighlight lang="xml">
<Entities>
  <Entity>activitypointer</Entity>
  <Entity>contact</Entity>
</Entities>
</syntaxhighlight>
Response:
<syntaxhighlight lang="xml">
<ArrayOfGetRecordCountResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <GetRecordCountResult name="activitypointer" count="69"/>
    <GetRecordCountResult name="account" count="19"/>
</ArrayOfGetRecordCountResult>
</syntaxhighlight>
</syntaxhighlight>


=== GET Select ===
=== GET Select ===


Template URL:
Template URL: <code>.../{entity}?$select={select}&$filter={filter}&$orderby={orderby} &$skip={skip}&$top={top}</code>
 
<code>.../{entity}?$select={select}&$filter={filter}&$orderby={orderby} &$skip={skip}&$top={top}</code>


Returns list of entities.
Returns list of entities.
Line 126: Line 179:
{| class="wikitable"
{| class="wikitable"
|-
|-
| {entity}  || determine the entity to retrieve, optionally, you can specify entity id to retrieve in the following format: account(guid’300a4f0b-99dc-4ba5-95bd-d41abf61dc10′)
| {entity}  || determine the entity to retrieve, optionally, you can specify entity id to retrieve in the following format: account(guid'300a4f0b-99dc-4ba5-95bd-d41abf61dc10')
|-
|-
| {select}  || determine attributes to retrieve, separated by comma
| {select}  || determine attributes to retrieve, separated by comma
Line 162: Line 215:
{| class="wikitable"
{| class="wikitable"
|-
|-
| string value  || “string”, or ‘string’
| string value  || “string”, or 'string'
|-
|-
| integer value  || 0, 1, 2, ….
| integer value  || 0, 1, 2, ….
Line 177: Line 230:
|}
|}


Sample URL: <syntaxhighlight lang="xml">https://{organization}.rescocrm.com/rest/v1/data/account?$select=name,address1_city,emailaddress1&$filter=name%20LIKE%20’C%&$orderby=address1_city&$skip=2&$top=5</syntaxhighlight>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/account?$select=name,address1_city,emailaddress1&$filter=name%20LIKE%20'C%'&$orderby=address1_city&$skip=2&$top=5</nowiki></code>


Response:
Response:
Line 231: Line 284:
Fetch query. Return list of entities defined by fetch.
Fetch query. Return list of entities defined by fetch.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data</nowiki></code>


Request:
Request:
Line 292: Line 345:
Default PrimaryKey is “id”.
Default PrimaryKey is “id”.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data/Create</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/Create</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entity EntityName=‘account‘ [PrimaryKey=’name;address1_city‘]>
<Entity EntityName='account' [PrimaryKey='name;address1_city']>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <name>My Name</name>
 <name>My Name</name>
Line 314: Line 367:
Create multiple entities. The entity is defined same as for Create method.
Create multiple entities. The entity is defined same as for Create method.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data/CreateMultiple</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/CreateMultiple</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entities xmlns=‘http://schemas.resco.net/XRM/EntitySet‘>
<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
  <name>My Name 1</name>
  <name>My Name 1</name>
Line 325: Line 378:
  <revenue>123456.789</revenue>
  <revenue>123456.789</revenue>
 </Entity>
 </Entity>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <name>My Name 2</name>
  <name>My Name 2</name>
Line 342: Line 395:
{create} (optional) — Determine whether the entity should be created if it does not exist.
{create} (optional) — Determine whether the entity should be created if it does not exist.


Sample URL: <code>https://{organization}.rescocrm.com/rest/v1/data/Update</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/Update</nowiki></code>


Optional URL: <code>https://{organization}.rescocrm.com/rest/v1/data/Update?$create=true</code>
Optional URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/Update?$create=true</nowiki></code>




Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entity EntityName=‘account‘ [PrimaryKey=‘name;address1_city‘]>
<Entity EntityName='account' [PrimaryKey='name;address1_city']>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <name>My Name 2</name>
 <name>My Name 2</name>
Line 365: Line 418:
{create} (optional) — Determine whether the entity should be created if it does not exist.
{create} (optional) — Determine whether the entity should be created if it does not exist.


Sample URL: <code>https://{organization}.resccrm.com/rest/v1/data/UpdateMultiple</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/UpdateMultiple</nowiki></code>


Optional URL: <code>https://{organization}.resccrm.com/rest/v1/data/UpdateMultiple?$create=true</code>
Optional URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/UpdateMultiple?$create=true</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entities xmlns=‘http://schemas.resco.net/XRM/EntitySet‘>
<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
   <name>My Name 1</name>
   <name>My Name 1</name>
Line 378: Line 431:
  <revenue>123456.789</revenue>
  <revenue>123456.789</revenue>
 </Entity>
 </Entity>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <name>My Name 2</name>
  <name>My Name 2</name>
Line 390: Line 443:
Delete entity. Optional, the primary key can be specified by “PrimaryKey” attribute. Default PrimaryKey is “id”.
Delete entity. Optional, the primary key can be specified by “PrimaryKey” attribute. Default PrimaryKey is “id”.


Sample URL: <code>https://{organization}.resccrm.com/rest/v1/data/Delete</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/Delete</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entity EntityName=‘account‘>
<Entity EntityName='account'>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
</Entity></syntaxhighlight>
</Entity></syntaxhighlight>
Line 400: Line 453:
With PrimaryKey:
With PrimaryKey:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entity EntityName=‘account‘ PrimaryKey=‘name;address1_city‘>
<Entity EntityName='account' PrimaryKey='name;address1_city'>
 <name>My Name 3</name>
 <name>My Name 3</name>
 <address1_city>Bratislava</address1_city>
 <address1_city>Bratislava</address1_city>
Line 409: Line 462:
Delete multiple entities. The entity is defined the same way as for Delete method.
Delete multiple entities. The entity is defined the same way as for Delete method.


Sample URL: <code>https://{organization}.resccrm.com/rest/v1/data/DeleteMultiple</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/DeleteMultiple</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entities xmlns=‘http://schemas.resco.net/XRM/EntitySet‘>
<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id> </Entity>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id> </Entity>
 <Entity EntityName=‘account‘>
 <Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
 </Entity>
 </Entity>
Line 431: Line 484:
* Delete – Delete entity
* Delete – Delete entity


Sample URL: <code>https://{organization}.resccrm.com/rest/v1/data/Execute</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/Execute</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<Entity EntityName=‘account‘ Action=‘ Create‘ [PrimaryKey=‘name;address1_city‘] xmlns=‘http://schemas.resco.net/XRM/Execute‘>
<Entity EntityName='account' Action='Create' [PrimaryKey='name;address1_city'] xmlns='http://schemas.resco.net/XRM/Execute'> <!-- parameter in [] is optional -->
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 <name>My Name</name>
 <name>My Name</name>
Line 448: Line 501:
</Response></syntaxhighlight>
</Response></syntaxhighlight>


=== Post ExecuteMultiple ===
=== POST ExecuteMultiple ===


Allow to execute specified operations on multiple entities, such as Create, Update, Upsert and Delete.
Allow to execute specified operations on multiple entities, such as Create, Update, Upsert, and Delete.
* ContinueOnError – Determine whether to continue executing operation on error.
* ContinueOnError – Determine whether to continue executing an operation on error.
* TransactionType – Determine transaction operation:
* TransactionType – Determine transaction operation:
* None – execute multiple will not run in transaction
* None – execute multiple will not run in a transaction
* RollbackOnError – execute multiple transaction will roll back on error
* RollbackOnError – execute multiple transaction will roll back on error
* CommitOnError – execute multiple transaction will commit on error
* CommitOnError – execute multiple transaction will commit on error
Line 463: Line 516:
* Delete – Delete entity
* Delete – Delete entity


Sample URL: <code>https://{organization}.resccrm.com/rest/v1/data/ExecuteMultiple</code>
Sample URL: <code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ExecuteMultiple</nowiki></code>


Request:
Request:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<ExecuteMultiple TransactionType=‘RollbackOnError‘ ContinueOnError=‘false‘ xmlns=‘http://schemas.resco.net/XRM/Execute‘>
<ExecuteMultiple TransactionType='RollbackOnError' ContinueOnError='false' xmlns='http://schemas.resco.net/XRM/Execute'>
 <Entity EntityName=‘account‘ Action=‘Create‘>
 <Entity EntityName='account' Action='Create'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name</name>
  <name>My Name</name>
Line 474: Line 527:
  <revenue>123456.789</revenue>
  <revenue>123456.789</revenue>
 </Entity>
 </Entity>
 <Entity EntityName=‘account‘ Action=‘Update‘>
 <Entity EntityName='account' Action='Update'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name 2</name>
  <name>My Name 2</name>
 </Entity>
 </Entity>
 <Entity EntityName=‘account‘ Action=‘Upsert‘>
 <Entity EntityName='account' Action='Upsert'>
  <id>2607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <id>2607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name 3</name>
  <name>My Name 3</name>
  <revenue2>987654.321</revenue2>
  <revenue2>987654.321</revenue2>
 </Entity>
 </Entity>
 <Entity EntityName=‘account‘ Action=‘Delete‘>
 <Entity EntityName='account' Action='Delete'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
 </Entity>
 </Entity>
Line 501: Line 554:
   <Code>500</Code>
   <Code>500</Code>
   <Reason>KeyNotFoundException</Reason>
   <Reason>KeyNotFoundException</Reason>
   <Detail>The given attribute ‘revenue2’ was not present in the entity metadata.</Detail>
   <Detail>The given attribute 'revenue2' was not present in the entity metadata.</Detail>
   <StackTrace>…</StackTrace>
   <StackTrace>…</StackTrace>
  </Fault>
  </Fault>
Line 509: Line 562:
 </Response>
 </Response>
</MultipleResponse></syntaxhighlight>
</MultipleResponse></syntaxhighlight>
=== POST Export ===
Export the organization data and metadata.
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/{organization}/Export</nowiki></code>
Example of a body request:
<syntaxhighlight lang="xml">
<ExportRequest>
    <Type>Metadata Data Localization Process Plugin Project</Type>
    <Entities>
        <!-- records of these entities will be exported -->
        <Entity>account</Entity>
        <Entity>contact</Entity>
    </Entities>
</ExportRequest>
</syntaxhighlight>
Type defines what should be exported, e.g if you want to export projects only: <Type>Project</Type>
If you want to export all, use <Type>All</Type>
Response: stream
=== POST Import ===
Import the organization data and metadata.
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/{organization}/Import?mode={mode}&publish={publish}</nowiki></code>
Mode:
* Import = 0 - Apply changes from import schema, but do not remove missing entities or attributes
* Update = 2 - Apply changes from import schema, but remove missing entities or attributes to match exactly imported schema. Loss of data may occur on removed entities or attributes.
Publish:
* true - import will be applied
* false - preview only (what will be changed/imported)
Body:
:Binary data (exported organization zip file)
If you want to enable asynchronous data import, add the following key-value pair to the header:
Key: Prefer
Value: respond-async
=== POST ExportProject ===
Export the complete app project definition to a file. You need to specify project name or ID as a parameter.
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ExportProject?$id={id}</nowiki></code>
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ExportProject?$name={name}</nowiki></code>
Response: Binary project data.
=== POST ImportProject (and publish) ===
Replace the content of an existing app project with the imported file. Specify destination project ID or name. The project must already exist. Use <code>&$publish=true</code> to automatically publish the project.
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ImportProject?$id={id}&$publish={publish}</nowiki></code>
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ImportProject?$name={name}&$publish={publish}</nowiki></code>
BODY:
Binary project data.
=== POST GenerateReport ===
Generate a mobile report.
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/GenerateReport</nowiki></code>
Examples of body requests:
a) Directly define report's data source record as entityid
<syntaxhighlight lang="xml">
<GenerateReportRequest>
  <ReportId>07e91ed7-ab9e-4807-acaa-27b8791451e0</ReportId>
  <EntityId>022e0024-35ca-41ba-a8cc-2f5ff304a919</EntityId>
  <GenerateReportFormat>Pdf</GenerateReportFormat>
  <Variables>
    <Variable name="name1">value1</Variable>
    <Variable name="name2">value2</Variable>
  </Variables>
</GenerateReportRequest>
</syntaxhighlight>
b) Fetch for report's data source records
<syntaxhighlight lang="xml">
<GenerateReportRequest>
    <ReportId>bbaade3e-0c9d-41c8-af0f-cc7b8c2b21bd</ReportId>
    <Fetch>
        <entity name="account">
            <attribute name="id"/>
            <filter>
                <condition attribute="id" operator="in">
                    <value>190C065A-9A2D-454A-A6BA-AAA29718C101</value>
                </condition>
            </filter>
        </entity>
    </Fetch>
    <Variables>
        <Variable name="name1">value2</Variable>
        <Variable name="name2">value1</Variable>
    </Variables>
    <GenerateReportFormat>Pdf</GenerateReportFormat>
</GenerateReportRequest>
</syntaxhighlight>
c) Request with custom report body.
<syntaxhighlight lang="xml">
<GenerateReportRequest>
  <ReportId>07e91ed7-ab9e-4807-acaa-27b8791451e0</ReportId>
  <Data>&lt;Report&gt;&lt;Styles&gt;&lt;Style Name=&quot;H1&quot;&gt;&lt;Background&gt;#0026d658&lt;/Background&gt;&lt;BorderColor&gt;#00000000&lt;/BorderColor&gt;&lt;BorderThickness&gt;0,0,0,0&lt;/BorderThickness&gt;&lt;FontSize&gt;15&lt;/FontSize&gt;&lt;FontWeight&gt;Normal&lt;/FontWeight&gt;&lt;Foreground&gt;#FF22e675&lt;/Foreground&gt;&lt;HorizontalAlignment&gt;Near&lt;/HorizontalAlignment&gt;&lt;Margin&gt;0,0,0,0&lt;/Margin&gt;&lt;Padding&gt;0,0,0,0&lt;/Padding&gt;&lt;VerticalAlignment&gt;Near&lt;/VerticalAlignment&gt;&lt;/Style&gt;&lt;Style Name=&quot;Normal&quot;&gt;&lt;Background&gt;#00000000&lt;/Background&gt;&lt;BorderColor&gt;#00000000&lt;/BorderColor&gt;&lt;BorderThickness&gt;0,0,0,0&lt;/BorderThickness&gt;&lt;FontSize&gt;10&lt;/FontSize&gt;&lt;FontWeight&gt;Normal&lt;/FontWeight&gt;&lt;Foreground&gt;#FF000000&lt;/Foreground&gt;&lt;HorizontalAlignment&gt;Near&lt;/HorizontalAlignment&gt;&lt;Margin&gt;0,0,0,0&lt;/Margin&gt;&lt;Padding&gt;0,0,0,0&lt;/Padding&gt;&lt;VerticalAlignment&gt;Near&lt;/VerticalAlignment&gt;&lt;/Style&gt;&lt;/Styles&gt;&lt;Variables&gt;&lt;Variable Name=&quot;src&quot; Type=&quot;Fetch&quot; Required=&quot;false&quot; Visible=&quot;false&quot; Source=&quot;true&quot; Lazy=&quot;true&quot; Fetch=&quot;&amp;lt;fetch&amp;gt;&amp;lt;entity name=&amp;quot;account&amp;quot;/&amp;gt;&amp;lt;/fetch&amp;gt;&quot;/&gt;&lt;Variable Name=&quot;str&quot; Type=&quot;String&quot; Required=&quot;true&quot; Visible=&quot;true&quot; Source=&quot;false&quot; Lazy=&quot;false&quot;/&gt;&lt;/Variables&gt;&lt;Body Width=&quot;595&quot; Height=&quot;842&quot; Margin=&quot;20&quot;&gt;&lt;Variables/&gt;&lt;Header&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Simple Account report with account records names&quot; Style=&quot;H1&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Header&gt;&lt;Repeater Alias=&quot;account&quot; FetchVariable=&quot;src&quot;&gt;&lt;Variables/&gt;&lt;Header&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Account Name&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Header&gt;&lt;Grid&gt;&lt;Text Binding=&quot;Value&quot; Content=&quot;account.name&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Grid&gt;&lt;/Repeater&gt;&lt;Footer&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Martin Test&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Footer&gt;&lt;/Body&gt;&lt;/Report&gt;</Data>
  <EntityId>022e0024-35ca-41ba-a8cc-2f5ff304a919</EntityId>
  <GenerateReportFormat>Pdf</GenerateReportFormat>
  <Variables>
    <Variable name="name1">value1</Variable>
    <Variable name="name2">value2</Variable>
  </Variables>
</GenerateReportRequest>
</syntaxhighlight>
;Format possibilities:
<syntaxhighlight lang="xml">
<GenerateReportFormat>Pdf</GenerateReportFormat>
<GenerateReportFormat>Html</GenerateReportFormat>
<GenerateReportFormat>Word</GenerateReportFormat>
<GenerateReportFormat>Excel</GenerateReportFormat>
</syntaxhighlight>
;Time zone:
<syntaxhighlight lang="xml">
<TimeZoneOffset>-120</TimeZoneOffset>
</syntaxhighlight>
{{Note|Custom fonts are normally ignored for server-generated reports. If you are using an on-premises deployment of Resco Cloud, you can [[Resco_Cloud_on_premises#Custom_fonts_for_reports|copy the fonts to the appropriate folder on the server]].|Tip}}
=== POST ExecuteWorkflow ===
Allows you to start a [[Server processes|server process]].
Sample URL:
<code><nowiki>https://{organization}.app.resco.net/rest/v1/data/ExecuteWorkflow</nowiki></code>
Request:
<syntaxhighlight lang="xml">
<WorkflowExecuteRequest xmlns="http://schemas.resco.net/XRM/OrganizationService">
                <WorkflowReference>resco_workflow:C0A79A17-FDDD-4152-9B19-F24FAF7D8095</WorkflowReference>
                <PrimaryEntity Name="account">
                                <name>Entity name</name>
                                <country>XX</country>
                </PrimaryEntity>
                <PrimaryReference>account:56de02f2-732a-4020-837e-93561c70ad07</PrimaryReference>
                <InputVariables>
                                <Variable Name="Test1" Type="Integer" Value="50" />
                                <Variable Name="Test2" Type="String" Value="string" />
                                <Variable Name="Test3" Type="Float" Value="45.26" />
                                <Variable Name="Test4" Type="DateTme" Value="2021-18-01T16:09:53Z" />
                                <Variable Name="Test5" Type="Decimal" Value="65.26" />
                                <Variable Name="Test6" Type="BigInt" Value="156" />
                                <Variable Name="Test7" Type="Lookup" Value="contact:826191dc-2dea-47f7-9b38-616b22129d8b" />
                </InputVariables>
                <OutputVariables>
                                <Variable>Var1</Variable>
                                <Variable>Var2</Variable>
                </OutputVariables>
</WorkflowExecuteRequest>
</syntaxhighlight>
* WorkflowReference - EntityReference to record in resco_workflow entity.
* PrimaryEntity - Determine the primary entity used in the workflow as the 'Entity' variable. It can be defined as a new Entity.
* PrimaryReference - Determine the primary entity used in the workflow as the 'Entity' variable. It can be defined as an EntityReference to an existing entity record.
* InputVariables - Determine input variables that can be used in the workflow.
* OutputVariables - Determine names of variables that should be returned from the workflow.
Result:
<syntaxhighlight lang="xml">
<WorkflowExecuteResult>
                <Result>Succeeded</Result>
                <Saved>true</Saved>
                <Log>Workflow log.</Log>
                <OutputVariables>
                                <Variable Name="Var1" Type="Integer" Value="100" />
                                <Variable Name="Var2" Type="String" Value="string + output" />
                </OutputVariables>
</WorkflowExecuteResult>
</syntaxhighlight>
* Result - Determine the result status of the workflow (InProgress, Succeeded, Failed, Canceled).
* Saved - Determine whether the WorkflowExecuteRequest.PrimaryEntity was changed and updated after workflow execution.
* Log - Determine the result log printed by workflow.
* OutputVariables - Contains the output variables returned from the workflow.
== Asynchronous operations ==
All operations with "Multiple" in their names support asynchronous execution. Use the <code>Prefer</code> header to instruct the server to use async operations:
Prefer: respond-async
Prefer: respond-async, wait=10
The <code>wait</code> HTTP preference is optional. It indicates the maximum duration the client is willing to wait for a response. The default value is 20 seconds.
The server returns "200 OK" when completed within the wait time or "202 Accepted" when not.
To poll the current status of the async operation, execute the "Multiple" method with an empty body and <code>$ticket={ticket}</code> query string, where the <code>{ticket}</code> is returned with the first request "202 Accepted".
There is a response header "Progress" with the progress of the async operation.
== Webhooks ==
Resco Cloud REST API supports webhooks. A create, update, or delete operation on the server can trigger a callback to a URL of your choosing.
CreateWebhook: <code>/$hook?$entity={entity}&$action={action}</code>
* entity: entity name
* action: one of [Create | Update | Delete]
* POST BODY: <code><Url><CallbackUrl>URL to invoke</CallbackUrl></Url> </code>
* RESPONSE HEADER: Location: URL to delete webhook
The BODY of the request to the external URL is in JSON format: <code>'{ "id": "record id" }'</code>
== Sample C# project ==
For your convenience, we have prepared a C# project that implements the data service.
* https://app.resco.net/docs/RescoCRM.SDK.zip - source code for Visual Studio
* https://www.nuget.org/packages/Resco.Cloud.Client/ - library with regular updates
== See also ==
Resco also offers you a development kit that allows you to develop your own plugins for Resco Cloud. Plugins can be used in [[Admin_Console#Processes|processes]]:
* [https://app.resco.net/docs/RescoCRM.Plugin.SDK.zip RescoCRM Plugin SDK]




[[Category:Resco Cloud]]
[[Category:Resco Cloud]]

Latest revision as of 08:29, 4 September 2024

Resco CRM connector is a group of web API services that you can use to connect your third-party backend to Resco Cloud to exchange data between the systems. These are the components involved in Resco CRM Connector.

Resco crm connector architecture

Resco Cloud and mobile apps are provided by Resco. Resco Cloud allows you to define schema and stores data for mobile apps, which is used to display the data.

You can now build your own Resco CRM Connector to enable the synchronization between your backend system and the Resco Cloud. Resco Cloud acts as a passive module — it does not initiate any synchronization. Mobile apps must initiate the synchronization process to download/upload data. This also applies to Resco CRM Connector. It must determine when/whether to synchronize ERP system data with data stored on the Resco Cloud. For example, every hour, every day, etc., depends on how current the data must be on the clients. To check whether there are new/updated data on the Resco Cloud use “GetMaxRowVersion” web service method to get the current row version. If the current row version changed from the last stored row version, there are new changes available on the Resco Cloud.

Available APIs

Resco CRM Connector offers multiple APIs:

This article describes the REST data service.

Data types

  • UniqueIdentifier
  • String
  • Integer
  • Float
  • Decimal
  • DateTime
  • Picklist
  • PicklistMap
  • Boolean
  • Money
  • Binary
  • Lookup
  • RowVersion
  • PartyList

By default, the data type format in data service requests and responses is in invariant culture (for example, the decimal separator is always a dot).

Date fields are in UTC time, in the following format: yyyy-MM-ddTHH:mm:ssZ; for example, 2020-12-12T09:00:00. Optionally, you can use syntax defined in RFC 3339 to modify this format.

Lookup fields are essentially strings in the following formats:

  • entity:id (for create/update requests)
  • entity:id:name (for fetch requests)

PartyList fields use the following format (parts in square brackets are optional):

<party [addressused='rajesh@example.com']>entity:id[:name]</party>
<party [addressused='howard@example.com']>entity:id[:name]</party>
...

Data service

Data service helps you access and manipulate data on Resco CRM server. The web service URL depends on server settings; whether the server uses domain organization selection or simple URL organization selection.

  • URL organization base web service URL is: https://example.com/rest/v1/data/{organization}
  • Domain organization base web service URL is: https://{organization}.example.com/rest/v1/data
Examples
  • Resco Cloud server uses the following domain organization selection: https://{organization}.app.resco.net/rest/v1/data
  • Resco Inspections cloud server uses the following domain organization selection: https://inspections.resco.net/rest/v1/data/{organization}
  • Resco Routes cloud server uses the following domain organization selection: https://routes.resco.net/rest/v1/data/{organization}

Web request requirements

Method: GET/POST

Content-Type: application/xml; charset=utf-8

Authorization: Basic BASE64(login:password)

Methods

POST WhoAmI
POST GetMaxRowVersion
GET Select
POST Fetch
POST Create
POST CreateMultiple
POST Update
POST UpdateMultiple
POST Delete
POST DeleteMultiple
POST Execute
POST ExecuteMultiple
POST ExportProject
POST ImportProject
POST GenerateReport
POST ExecuteWorkflow

POST WhoAmI

Return organization ID and user ID.

No parameters.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/WhoAmI

Response:

<?xml version=“1.0” encoding=“utf-8“?>
<WhoAmI xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance“>          
<OrganizationId>87ddc2f8-d0d1-4ad6-a925-5765a7a46edd</ OrganizationId>          
<UserId>601d9d17-89b4-e111-9c9a-00155d0b710a</UserId>
</WhoAmI>

POST GetMaxRowVersion

Return max row version for the database. Row version is counter of every change in database. It helps to determine changes from last synchronization. Each entity has system attribute “rowversion” which determine the version (or timestamp) of last change for the specified row.

No parameters.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/GetMaxRowVersion

Response:

<?xml version=“1.0” encoding=“utf-8“?>
<string>3665</string>

POST GetRecordCount

Get the number of entity records.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/GetRecordCount

Examples of body requests:

<Entities>
   <Entity>activitypointer</Entity>
   <Entity>contact</Entity>
</Entities>

Response:

<ArrayOfGetRecordCountResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <GetRecordCountResult name="activitypointer" count="69"/>
    <GetRecordCountResult name="account" count="19"/>
</ArrayOfGetRecordCountResult>

GET Select

Template URL: .../{entity}?$select={select}&$filter={filter}&$orderby={orderby} &$skip={skip}&$top={top}

Returns list of entities.

Parameters:

{entity} determine the entity to retrieve, optionally, you can specify entity id to retrieve in the following format: account(guid'300a4f0b-99dc-4ba5-95bd-d41abf61dc10')
{select} determine attributes to retrieve, separated by comma
{filter} determine entity filter
{orderby} – determine sort, optionally include “desc” keyword. Separated by comma.
{skip} – determine number of entities to skip
{top} – determine number of entities to return

A condition is defined like: {left identifier} {comparison statement} {right identifier} {and/or} .... The left identifier is always the attribute name.

Comparison statements can be any of following:

eq, =, == equal
ne, !=, <> not equal
gt, > greater than
ge, >= greater than equal
lt, < less than
le, <= less than equal
like, not-like like or not like

Right identifier can be any of following:

string value “string”, or 'string'
integer value 0, 1, 2, ….
null, not-null

Conditions can be joined using:

and &&
or ||

Sample URL: https://{organization}.app.resco.net/rest/v1/data/account?$select=name,address1_city,emailaddress1&$filter=name%20LIKE%20'C%'&$orderby=address1_city&$skip=2&$top=5

Response:

<?xml version=“1.0” encoding=”utf-8“?>
<EntitySet xmlns=“http://schemas.resco.net/XRM/OrganizationService“>
<Metadata PrimaryEntity=“account“>
  <Attributes>
   <Attribute EntityName=“account” AttributeName=“name” Name=“name” Type=“String“/>
   <Attribute EntityName=“account” AttributeName=“address1_city” Name=“address1 _city” Type=“String“/>
   <Attribute EntityName=“account” AttributeName=“emailaddress1” Name=“emailaddress1” Type=“String“/>
   <Attribute EntityName=“account” AttributeName=“id” Name=”id” Type=“UniqueIdentifier“/>
  </Attributes>
</Metadata>
<Entities>
  <Entity EntityName=“account“>
   <name>Cash and Carry Bikes</name>
   <address1_city>Dallas</address1_city>
   <emailaddress1>someone@example.com</emailaddress1>
   <id>b9ca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
  </Entity>
  <Entity EntityName=“account“>
   <name>Convenient Bike Shop</name>
   <address1_city>Everett</address1_city>
   <emailaddress1>someone@example.com</emailaddress1>
   <id>bdca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
  </Entity>
   <Entity EntityName=“account“>
   <name>Cheap n Best bikes</name>
   <address1_city>Redmond</address1_city>
   <emailaddress1>someone@example.com</emailaddress1>
   <id>bbca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
  </Entity>
   <Entity EntityName=“account“>
   <name>Cool Ride Store</name>
   <address1_city>Seattle</address1_city>
   <emailaddress1>someone@example.com</emailaddress1>
   <id>beca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
  </Entity>
   <Entity EntityName=“account“>
   <name>Certified Bicycle Supply</name>
   <address1_city>West Covina</address1_city>
   <emailaddress1>someone@example.com</emailaddress1>
   <id>baca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
  </Entity>
</Entities>
</EntitySet>

POST Fetch

Fetch query. Return list of entities defined by fetch.

Sample URL: https://{organization}.app.resco.net/rest/v1/data

Request:

<fetch page=“2  count=“5” paging-cookie=“optional PagingCookie from previous fetch“>
<entity name=“account“>
  <attribute name=“id” />
  <attribute name=“name” />
  <order attribute=“name” descending=“true” />
  <filter>
   <condition attribute=“name” operator=“like” value=“b%” />
  </filter>
</entity>
</fetch>

Response:

<?xml version=“1.0” encoding=”utf-8“?>
<EntitySet xmlns=“http://schemas.resco.net/XRM/OrganizationService“>
<Metadata PrimaryEntity=“account“>
  <Attributes>
   <Attribute EntityName=“account” AttributeName=“id” Type=“UniqueIdentifier“/>
   <Attribute EntityName=“account” AttributeName=“name” Name=“id” Name=“name” Type=“String“/>
  </Attributes>
</Metadata>
<Entities>
  <Entity EntityName=“account“>
   <id>b3ca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
   <name>Bikes unlimited</name>
  </Entity>
  <Entity EntityName=“account“>
   <id>b2ca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
   <name>Bike-o-maniac store</name>
  </Entity>
  <Entity EntityName=“account“>
   <id>b1ca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
   <name>Bike Universe</name>
  </Entity>
  <Entity EntityName=“account“>
   <id>b0ca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
   <name>Bike Products and Accessories</name>
  </Entity>
  <Entity EntityName=“account“>
   <id>afca6c78-4e0b-df11-a3d5-0003ff9c98bb</id>
   <name>Bike Experts</name>
  </Entity>
</Entities>
<MoreRecords>true</MoreRecords>
<PagingCookie>&lt;cookie page=”2″&gt;&lt;name last=”Bike  Experts” descending=”1″ /&gt;&lt;id last=”afca6c78-4e0b-df11-a3d5-0003ff9c98bb” /&gt;&lt;/cookie&gt;</PagingCookie>
</EntitySet>

POST Create

Create entity and return entity ID. Optional, primary key can be specified by “PrimaryKey” attribute.

Default PrimaryKey is “id”.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/Create

Request:

<Entity EntityName='account' [PrimaryKey='name;address1_city']>
<id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
<name>My Name</name>
<address1_city>Bratislava</address1_city>
<revenue>123456.789</revenue>
</Entity>

Response:

<?xml version=“1.0” encoding=“utf-8“?>
<guid>1607a7f7-c16f-4e19-849c-bad37ff59f5c</guid>

POST CreateMultiple

Create multiple entities. The entity is defined same as for Create method.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/CreateMultiple

Request:

<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
<Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
  <name>My Name 1</name>
  <address1_city>Bratislava</address1_city>
  <revenue>123456.789</revenue>
</Entity>
<Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <name>My Name 2</name>
  <address1_city>Bratislava</address1_city>
  <revenue>987654.321</revenue>
</Entity>
</Entities>

POST Update?$create={create}

Update entity. Optional, the primary key can be specified by “PrimaryKey” attribute. Default PrimaryKey is “id”.

Parameter:

{create} (optional) — Determine whether the entity should be created if it does not exist.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/Update

Optional URL: https://{organization}.app.resco.net/rest/v1/data/Update?$create=true


Request:

<Entity EntityName='account' [PrimaryKey='name;address1_city']>
<id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
<name>My Name 2</name>
<address1_city>Bratislava</address1_city>
<revenue>987654.321</revenue>
</Entity>

POST UpdateMultiple?$create={create}

Update multiple entities. The entity is defined the same way as for Update method.

Parameter:

{create} (optional) — Determine whether the entity should be created if it does not exist.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/UpdateMultiple

Optional URL: https://{organization}.app.resco.net/rest/v1/data/UpdateMultiple?$create=true

Request:

<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
<Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id>
<name>My Name 1</name>
  <address1_city>Bratislava</address1_city>
  <revenue>123456.789</revenue>
</Entity>
<Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
  <name>My Name 2</name>
  <address1_city>Bratislava</address1_city>
  <revenue>987654.321</revenue>
</Entity>
</Entities>

POST Delete

Delete entity. Optional, the primary key can be specified by “PrimaryKey” attribute. Default PrimaryKey is “id”.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/Delete

Request:

<Entity EntityName='account'>
<id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
</Entity>

With PrimaryKey:

<Entity EntityName='account' PrimaryKey='name;address1_city'>
<name>My Name 3</name>
<address1_city>Bratislava</address1_city>
</Entity>

POST DeleteMultiple

Delete multiple entities. The entity is defined the same way as for Delete method.

Sample URL: https://{organization}.app.resco.net/rest/v1/data/DeleteMultiple

Request:

<Entities xmlns='http://schemas.resco.net/XRM/EntitySet'>
<Entity EntityName='account'>
  <id>FE400D92-EFD6-4856-A0B4-94C63212D5C8</id> </Entity>
<Entity EntityName='account'>
  <id>D008549E-842F-46EC-9F76-ECC5F20A550D</id>
</Entity>
</Entities>

POST Execute

Allow to execute specified operation on entity, such as Create, Update, Upsert and Delete.

Action:

  • Create – Create entity
  • Update – Update entity
  • Upsert – If exist, Update entity; otherwise Create entity
  • Delete – Delete entity

Sample URL: https://{organization}.app.resco.net/rest/v1/data/Execute

Request:

<Entity EntityName='account' Action='Create' [PrimaryKey='name;address1_city'] xmlns='http://schemas.resco.net/XRM/Execute'> <!-- parameter in [] is optional -->
<id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
<name>My Name</name>
<address1_city>Bratislava</address1_city>
<revenue>123456.789</revenue>
</Entity>

Response:

<Response Action=“Create” xmlns=“http://schemas.resco.net/XRM/Execute“>
<Result Type=“guid“>1607a7f7-c16f-4e19-849c-bad37ff59f5c</Result>
</Response>

POST ExecuteMultiple

Allow to execute specified operations on multiple entities, such as Create, Update, Upsert, and Delete.

  • ContinueOnError – Determine whether to continue executing an operation on error.
  • TransactionType – Determine transaction operation:
  • None – execute multiple will not run in a transaction
  • RollbackOnError – execute multiple transaction will roll back on error
  • CommitOnError – execute multiple transaction will commit on error

Action:

  • Create – Create entity
  • Update – Update entity
  • Upsert – If exist, Update entity; otherwise Create entity
  • Delete – Delete entity

Sample URL: https://{organization}.app.resco.net/rest/v1/data/ExecuteMultiple

Request:

<ExecuteMultiple TransactionType='RollbackOnError' ContinueOnError='false' xmlns='http://schemas.resco.net/XRM/Execute'>
<Entity EntityName='account' Action='Create'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name</name>
  <address1_city>Bratislava</address1_city>
  <revenue>123456.789</revenue>
</Entity>
<Entity EntityName='account' Action='Update'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name 2</name>
</Entity>
<Entity EntityName='account' Action='Upsert'>
  <id>2607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
  <name>My Name 3</name>
  <revenue2>987654.321</revenue2>
</Entity>
<Entity EntityName='account' Action='Delete'>
  <id>1607A7F7-C16F-4E19-849C-BAD37FF59F5C</id>
</Entity>
</ExecuteMultiple>

Response:

<?xml version=“1.0” encoding=“utXRMf-8“?>
<MultipleResponse xmlns=“http://schemas.resco.net/XRM/Execute“>
<Response Action=“Create“>
  <Result Type=“guid“>1607a7f7-c16f-4e19-849c-bad37ff59f5c</Result> </Response>
<Response Action=“Update“>
  <Result Type=“bool“>true</Result>
</Response>
<Response Action=“Upsert“>
  <Fault xmlns=“http://schemas.resco.net/XRM/XRMServiceError“>
   <Code>500</Code>
   <Reason>KeyNotFoundException</Reason>
   <Detail>The given attribute 'revenue2' was not present in the entity metadata.</Detail>
   <StackTrace></StackTrace>
  </Fault>
</Response>
<Response Action=“Delete“>
  <Result Type=“bool“>true</Result>
</Response>
</MultipleResponse>

POST Export

Export the organization data and metadata.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/{organization}/Export

Example of a body request:

<ExportRequest>
    <Type>Metadata Data Localization Process Plugin Project</Type>
    <Entities>
        <!-- records of these entities will be exported -->
        <Entity>account</Entity>
        <Entity>contact</Entity>
    </Entities>
</ExportRequest>

Type defines what should be exported, e.g if you want to export projects only: <Type>Project</Type> If you want to export all, use <Type>All</Type>

Response: stream

POST Import

Import the organization data and metadata.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/{organization}/Import?mode={mode}&publish={publish}

Mode:

  • Import = 0 - Apply changes from import schema, but do not remove missing entities or attributes
  • Update = 2 - Apply changes from import schema, but remove missing entities or attributes to match exactly imported schema. Loss of data may occur on removed entities or attributes.

Publish:

  • true - import will be applied
  • false - preview only (what will be changed/imported)

Body:

Binary data (exported organization zip file)

If you want to enable asynchronous data import, add the following key-value pair to the header:

Key: Prefer
Value: respond-async

POST ExportProject

Export the complete app project definition to a file. You need to specify project name or ID as a parameter.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/ExportProject?$id={id}

https://{organization}.app.resco.net/rest/v1/data/ExportProject?$name={name}

Response: Binary project data.

POST ImportProject (and publish)

Replace the content of an existing app project with the imported file. Specify destination project ID or name. The project must already exist. Use &$publish=true to automatically publish the project.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/ImportProject?$id={id}&$publish={publish}

https://{organization}.app.resco.net/rest/v1/data/ImportProject?$name={name}&$publish={publish}

BODY:

Binary project data.

POST GenerateReport

Generate a mobile report.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/GenerateReport

Examples of body requests:

a) Directly define report's data source record as entityid

<GenerateReportRequest>
  <ReportId>07e91ed7-ab9e-4807-acaa-27b8791451e0</ReportId>
  <EntityId>022e0024-35ca-41ba-a8cc-2f5ff304a919</EntityId>
  <GenerateReportFormat>Pdf</GenerateReportFormat>
  <Variables>
    <Variable name="name1">value1</Variable>
    <Variable name="name2">value2</Variable>
  </Variables>
</GenerateReportRequest>

b) Fetch for report's data source records

<GenerateReportRequest>
    <ReportId>bbaade3e-0c9d-41c8-af0f-cc7b8c2b21bd</ReportId>
    <Fetch>
        <entity name="account">
            <attribute name="id"/>
            <filter>
                <condition attribute="id" operator="in">
                    <value>190C065A-9A2D-454A-A6BA-AAA29718C101</value>
                </condition>
            </filter>
        </entity>
    </Fetch>
    <Variables>
        <Variable name="name1">value2</Variable>
        <Variable name="name2">value1</Variable>
    </Variables>
    <GenerateReportFormat>Pdf</GenerateReportFormat>
</GenerateReportRequest>

c) Request with custom report body.

<GenerateReportRequest>
  <ReportId>07e91ed7-ab9e-4807-acaa-27b8791451e0</ReportId>
  <Data>&lt;Report&gt;&lt;Styles&gt;&lt;Style Name=&quot;H1&quot;&gt;&lt;Background&gt;#0026d658&lt;/Background&gt;&lt;BorderColor&gt;#00000000&lt;/BorderColor&gt;&lt;BorderThickness&gt;0,0,0,0&lt;/BorderThickness&gt;&lt;FontSize&gt;15&lt;/FontSize&gt;&lt;FontWeight&gt;Normal&lt;/FontWeight&gt;&lt;Foreground&gt;#FF22e675&lt;/Foreground&gt;&lt;HorizontalAlignment&gt;Near&lt;/HorizontalAlignment&gt;&lt;Margin&gt;0,0,0,0&lt;/Margin&gt;&lt;Padding&gt;0,0,0,0&lt;/Padding&gt;&lt;VerticalAlignment&gt;Near&lt;/VerticalAlignment&gt;&lt;/Style&gt;&lt;Style Name=&quot;Normal&quot;&gt;&lt;Background&gt;#00000000&lt;/Background&gt;&lt;BorderColor&gt;#00000000&lt;/BorderColor&gt;&lt;BorderThickness&gt;0,0,0,0&lt;/BorderThickness&gt;&lt;FontSize&gt;10&lt;/FontSize&gt;&lt;FontWeight&gt;Normal&lt;/FontWeight&gt;&lt;Foreground&gt;#FF000000&lt;/Foreground&gt;&lt;HorizontalAlignment&gt;Near&lt;/HorizontalAlignment&gt;&lt;Margin&gt;0,0,0,0&lt;/Margin&gt;&lt;Padding&gt;0,0,0,0&lt;/Padding&gt;&lt;VerticalAlignment&gt;Near&lt;/VerticalAlignment&gt;&lt;/Style&gt;&lt;/Styles&gt;&lt;Variables&gt;&lt;Variable Name=&quot;src&quot; Type=&quot;Fetch&quot; Required=&quot;false&quot; Visible=&quot;false&quot; Source=&quot;true&quot; Lazy=&quot;true&quot; Fetch=&quot;&amp;lt;fetch&amp;gt;&amp;lt;entity name=&amp;quot;account&amp;quot;/&amp;gt;&amp;lt;/fetch&amp;gt;&quot;/&gt;&lt;Variable Name=&quot;str&quot; Type=&quot;String&quot; Required=&quot;true&quot; Visible=&quot;true&quot; Source=&quot;false&quot; Lazy=&quot;false&quot;/&gt;&lt;/Variables&gt;&lt;Body Width=&quot;595&quot; Height=&quot;842&quot; Margin=&quot;20&quot;&gt;&lt;Variables/&gt;&lt;Header&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Simple Account report with account records names&quot; Style=&quot;H1&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Header&gt;&lt;Repeater Alias=&quot;account&quot; FetchVariable=&quot;src&quot;&gt;&lt;Variables/&gt;&lt;Header&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Account Name&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Header&gt;&lt;Grid&gt;&lt;Text Binding=&quot;Value&quot; Content=&quot;account.name&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Grid&gt;&lt;/Repeater&gt;&lt;Footer&gt;&lt;Text Binding=&quot;Constant&quot; Content=&quot;Martin Test&quot; Style=&quot;Normal&quot; Column=&quot;0&quot; Row=&quot;0&quot; ColSpan=&quot;1&quot; RowSpan=&quot;1&quot;/&gt;&lt;/Footer&gt;&lt;/Body&gt;&lt;/Report&gt;</Data>
  <EntityId>022e0024-35ca-41ba-a8cc-2f5ff304a919</EntityId>
  <GenerateReportFormat>Pdf</GenerateReportFormat>
  <Variables>
    <Variable name="name1">value1</Variable>
    <Variable name="name2">value2</Variable>
  </Variables>
</GenerateReportRequest>
Format possibilities
<GenerateReportFormat>Pdf</GenerateReportFormat>
<GenerateReportFormat>Html</GenerateReportFormat>
<GenerateReportFormat>Word</GenerateReportFormat>
<GenerateReportFormat>Excel</GenerateReportFormat>
Time zone
<TimeZoneOffset>-120</TimeZoneOffset>
Tip Custom fonts are normally ignored for server-generated reports. If you are using an on-premises deployment of Resco Cloud, you can copy the fonts to the appropriate folder on the server.

POST ExecuteWorkflow

Allows you to start a server process.

Sample URL:

https://{organization}.app.resco.net/rest/v1/data/ExecuteWorkflow

Request:

<WorkflowExecuteRequest xmlns="http://schemas.resco.net/XRM/OrganizationService">
                <WorkflowReference>resco_workflow:C0A79A17-FDDD-4152-9B19-F24FAF7D8095</WorkflowReference>
                <PrimaryEntity Name="account">
                                <name>Entity name</name>
                                <country>XX</country>
                </PrimaryEntity>
                <PrimaryReference>account:56de02f2-732a-4020-837e-93561c70ad07</PrimaryReference>
                <InputVariables>
                                <Variable Name="Test1" Type="Integer" Value="50" />
                                <Variable Name="Test2" Type="String" Value="string" />
                                <Variable Name="Test3" Type="Float" Value="45.26" />
                                <Variable Name="Test4" Type="DateTme" Value="2021-18-01T16:09:53Z" />
                                <Variable Name="Test5" Type="Decimal" Value="65.26" />
                                <Variable Name="Test6" Type="BigInt" Value="156" />
                                <Variable Name="Test7" Type="Lookup" Value="contact:826191dc-2dea-47f7-9b38-616b22129d8b" />
                </InputVariables>
                <OutputVariables>
                                <Variable>Var1</Variable>
                                <Variable>Var2</Variable>
                </OutputVariables>
</WorkflowExecuteRequest>
  • WorkflowReference - EntityReference to record in resco_workflow entity.
  • PrimaryEntity - Determine the primary entity used in the workflow as the 'Entity' variable. It can be defined as a new Entity.
  • PrimaryReference - Determine the primary entity used in the workflow as the 'Entity' variable. It can be defined as an EntityReference to an existing entity record.
  • InputVariables - Determine input variables that can be used in the workflow.
  • OutputVariables - Determine names of variables that should be returned from the workflow.

Result:

<WorkflowExecuteResult>
                <Result>Succeeded</Result>
                <Saved>true</Saved>
                <Log>Workflow log.</Log>
                <OutputVariables>
                                <Variable Name="Var1" Type="Integer" Value="100" />
                                <Variable Name="Var2" Type="String" Value="string + output" />
                </OutputVariables>
</WorkflowExecuteResult>
  • Result - Determine the result status of the workflow (InProgress, Succeeded, Failed, Canceled).
  • Saved - Determine whether the WorkflowExecuteRequest.PrimaryEntity was changed and updated after workflow execution.
  • Log - Determine the result log printed by workflow.
  • OutputVariables - Contains the output variables returned from the workflow.

Asynchronous operations

All operations with "Multiple" in their names support asynchronous execution. Use the Prefer header to instruct the server to use async operations:

Prefer: respond-async
Prefer: respond-async, wait=10

The wait HTTP preference is optional. It indicates the maximum duration the client is willing to wait for a response. The default value is 20 seconds. The server returns "200 OK" when completed within the wait time or "202 Accepted" when not.

To poll the current status of the async operation, execute the "Multiple" method with an empty body and $ticket={ticket} query string, where the {ticket} is returned with the first request "202 Accepted".

There is a response header "Progress" with the progress of the async operation.

Webhooks

Resco Cloud REST API supports webhooks. A create, update, or delete operation on the server can trigger a callback to a URL of your choosing.

CreateWebhook: /$hook?$entity={entity}&$action={action}

  • entity: entity name
  • action: one of [Create | Update | Delete]
  • POST BODY: <Url><CallbackUrl>URL to invoke</CallbackUrl></Url>
  • RESPONSE HEADER: Location: URL to delete webhook

The BODY of the request to the external URL is in JSON format: '{ "id": "record id" }'

Sample C# project

For your convenience, we have prepared a C# project that implements the data service.

See also

Resco also offers you a development kit that allows you to develop your own plugins for Resco Cloud. Plugins can be used in processes: