WEB/REST services

As standard, beCPG offers an HTTP REST service called Remote API, which lets you:

  • import entity data in XML format,
  • export the data of an entity in XML format according to criteria (e.g. all the products that are validated and effective on the date DD/MM/YYYY).

This REST service lets you build interfaces with third-party software such as an ERP. By entity, we mean the product, the customer, the supplier, the project, etc., with all its information, dynamically and without development.

The exchange interface can therefore be implemented by a third-party tool whose role is to:

  • manage exchanges,
  • transform flows (transformation rules on lists of values, for example),
  • handle errors.

This third-party tool communicates with the Remote API to import and export beCPG data. 2 approaches are possible:

  • the client has a third-party tool to create the interface,
  • the client wants beCPG to set up a third-party tool to create the interface.

In addition, all the application's APIs are accessible via REST services:

  • CRUD (Create/Read/Update/Delete) operations
  • labeling
  • document generation
  • retrieval of versions and technical sheets
  • etc.

Versions

Different versions of the APIs exist depending on your version of beCPG. Backward compatibility is maintained. For example, the XML format is identical between versions 1 and 3.1.

The table below lists the different versions of the API and the main changes:

API version XML Support JSON Support Changes
4.0 Yes Yes Add pagination to List entity
3.4 Yes Yes Add nested datalist support, Add entity dictionary support
3.3 Yes Yes Add jsonParam prefix support
3.2 Yes Yes Add JSON Schema format
3.1 Yes Yes Add JSON params and negation in lists and fields
3.0 Yes Yes Add JSON format support
2.1 Yes No Add FORMULATE REPORT BRANCH MERGE on entity, Add compressParam option
2.0 Yes No Add filtering results by list and fields
1.0 Yes No Allow to GET PUT DELETE UPDATE and LIST entity

Below are the associated beCPG versions.

beCPG version Alfresco version Java version Platform Remote API
25.3.0 Alfresco 25.3 JDK 17 Docker 4.0
23.2.0 Alfresco 23.2 JDK 17 Docker 4.0
4.4.0 Alfresco 7.4 JDK 17 Docker 3.4
4.2.2 Alfresco 7.2 JDK 11 Docker 3.3
4.2.1 Alfresco 7.2 JDK 11 Docker 3.2
3.2.3 Alfresco 6.2 JDK 11 Docker 3.1
3.2.2 Alfresco 6.2 JDK 11 Docker 3.1
3.2.1 Alfresco 6.2 JDK 11 Docker 3.1
3.2.0 Alfresco 6.2 JDK 11 Docker 3.0
2.2.5 Alfresco 5.2 JDK 8 Docker 2.1
2.2.4 Alfresco 5.2 JDK 8 Docker 2.0
2.2.3 Alfresco 5.2 JDK 8 Docker 1.0
2.2 Alfresco 5.2 JDK 8 tc-server 1.0
2.1 Alfresco 5.1 JDK 7 tc-server 1.0
2.0 Alfresco 5.0.d JDK 7 tc-server 1.0
1.6 Alfresco 4.2.e JDK 7 tc-server 1.0

The options specific to each version of the API are marked [>= 3.1] in the documentation.

Publication channel batches

New API endpoints are available to manage publication channel batches:

  • GET /becpg/remote/channel/batch/start/{channelId}: starts a new batch for a specific channel.
  • GET /becpg/remote/channel/batch/ack/{batchId}: acknowledges a batch.
  • GET /becpg/remote/channel/batch/end/{batchId}: ends a batch.

beCPG API

The beCPG remote API offers the following REST URLs:

From version 1:

<url>/becpg/remote/entity/list?path={path}</url>
<url>/becpg/remote/entity/list?query={query}&maxResults={maxResults}</url>
<url>/becpg/remote/entity?nodeRef={nodeRef}</url>
<url>/becpg/remote/entity?path={path}</url>
<url>/becpg/remote/entity?query={query}</url>

From version 2.1:

<url>/becpg/remote/formulate?nodeRef={nodeRef}</url>
<url>/becpg/remote/formulate?path={path}</url>
<url>/becpg/remote/formulate?query={query}</url>
<url>/becpg/remote/merge?nodeRef={nodeRef}</url>
<url>/becpg/remote/check?nodeRef={nodeRef}</url>
<url>/becpg/remote/content?nodeRef={nodeRef}</url>
<url>/becpg/remote/branch?nodeRef={nodeRef}</url>
<url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}</url>
<url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}&locale={locale}</url>
<url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}&locale={locale}&format={format}</url>

The PUT/GET/POST/DELETE methods respectively add, find, update and delete entities in the PLM (product, customer, supplier, etc.).

From version 3.4:

<url>/becpg/remote/dictionary?type={type}</url>

List entities

The LIST query returns the list of entities, which can be filtered with advanced search criteria (for example, products modified since a given date).

<url>/becpg/remote/entity/list?path={path}</url>
<url>/becpg/remote/entity/list?query={query}&maxResults={maxResults}&fields={fields}</url>
<url>/becpg/remote/entity/list?path={path}&maxResults={maxResults}&fields={fields}</url>

The search syntax is the Alfresco FTS syntax, described in the Alfresco Search Services documentation. See also the Constructing Lucene Queries section.

Warning: depending on the syntax used, the search results may lag a few minutes behind the changes made in the system. This delay is due to indexing. To avoid it, use only searches with the db-afts syntax. Otherwise, shift your search criteria by 10 minutes. To test that your query is db-afts compatible, run it in the node browser with db-afts selected: your search should return results.

Transactional search (db-afts) supports the following criteria:

  • PARENT
  • TYPE
  • ASPECT
  • EXACTTYPE
  • EXACTASPECT
  • = (Property equality)
  • Date Range
  • AND NOT OR

More information on transactional searches:

https://docs.hyland.com/r/Alfresco/Alfresco-Search-Services/2.0/Alfresco-Search-Services

Example of a request that returns a Finished product from its ERP code:

 +TYPE:"bcpg:finishedProduct" AND =@bcpg\:erpCode:"codeErp" AND -ASPECT:"bcpg:compositeVersion"
 (-ASPECT:"bcpg:compositeVersion" excludes older versions)

The corresponding URL:

http://localhost:8080/alfresco/service/becpg/remote/entity?query=%2BTYPE%3A%22bcpg%3AfinishedProduct%22%20AND%20%3D%40bcpg%5C%3AerpCode%3A%22codeErp%22%20AND%20-ASPECT%3A%22bcpg%3AcompositeVersion%22

To get the encoded URL (in the Firefox console):

 encodeURIComponent('+TYPE:"bcpg:finishedProduct" AND =@bcpg\\:erpCode:"codeErp" AND -ASPECT:"bcpg:compositeVersion"')

The maxResults parameter specifies the number of results (-1 returns all the results).

The format parameter changes the response format:

  • format=xml (default)
  • format=json (JSON format)

The fields parameter specifies the fields or associations to extract in the results [>2.0]:

http://localhost/alfresco/service/becpg/remote/entity/list?query=%2BTYPE%3A%22bcpg%3AfinishedProduct%22&fields=bcpg:legalName,bcpg:clients

Pagination parameters [>=4.0]:

  • maxResults: defines the maximum number of results to return per request. If this parameter is omitted, the default value is 256. Use maxResults=-1 to retrieve all available results.

Note: When the fields parameter is used, pagination is automatically enabled, and the maxResults parameter is no longer considered.

  • skipCount: indicates the number of results to skip before returning results. This is useful for pagination.

Example: if skipCount is set to 10 and maxResults to 5, the response contains results 11 to 15.

http://localhost/alfresco/service/becpg/remote/entity/list?query=%2BTYPE%3A%22bcpg%3AfinishedProduct%22&maxResults=5&skipCount=10
  • page: lets you move from one page to the next by incrementing the value.

Note: When you reach the last page, the response returns hasMoreItems with the value false, meaning there are no more entities to retrieve.

Pagination fields in the API response:

  • hasMoreItems: a boolean indicating whether more results remain. If true, there are more results to retrieve.

  • count: the number of results returned in the current response.

Pagination makes it possible to handle large amounts of data efficiently.

Examples:

Sample bash script that retrieves a list of entities as an XML file:

#!/bin/sh

export REMOTE_SERVER=http://localhost:8080/alfresco/service/becpg/remote/entity
export REMOTE_USER=admin
echo "Enter password"
read REMOTE_PASSWORD

#Retrieve the list of nodes:

wget --quiet --http-user=$REMOTE_USER --http-password=$REMOTE_PASSWORD --header=Accept-Charset:iso-8859-1,utf-8 --header=Accept-Language:en-us -O list.xml $REMOTE_SERVER/list
count=1

#We go through the list
while [ -n "$nodeRef" -o $count = 1 ]
    do
       nodeRef=`cat list.xml | xpath -q -e //*[$count]/@nodeRef | sed s/nodeRef=//g |sed s/\"//g`
       echo "Getting node $nodeRef";
       # We save each node
       wget --quiet --http-user=$REMOTE_USER --http-password=$REMOTE_PASSWORD --header=Accept-Charset:iso-8859-1,utf-8 --header=Accept-Language:en-us -O entity_$count.xml $REMOTE_SERVER?nodeRef=$nodeRef
       count=$((count+1))
done

Get entity

Two REST services are available to get entities.

The remote API, using the following GET requests:

<url>/becpg/remote/entity?nodeRef={nodeRef}&format={format}</url>
  <url>/becpg/remote/entity?query={query}&format={format}</url>
  <url>/becpg/remote/entity?nodeRef={nodeRef}&lists={lists}&fields={fields}</url>
  <url>/becpg/remote/entity?query={query}&lists={lists}&fields={fields}</url>

A 404 error is returned if no entity matches the provided parameters.

The format parameter changes the response format:

  • format=xml (default)
  • format=json (JSON format) [>= 3.0]
  • format=json_schema (JSON Validation Schema) [>= 4.2.1]
  • format=xml_all (Contains the details of all associations)
  • format=xml_excel (Format suitable for use as a datasource in Excel)
  • format=xml_light (This format does not contain child type associations)
  • format=xsd (Extracts the XSD)
  • format=xsd_excel (Extracts the XSD for Excel)

Additional filter parameters lighten the response. There are 3 types of filtering [>=2.0]:

  • Properties filtering: include only listed properties (fields=bcpg:legalName)
  • Association filtering: include only listed associations (fields=bcpg:clients)
  • Lists filtering: include only listed lists (lists=bcpg:compoList)

In addition, you can extract the properties of an association by passing in the fields parameter the name of the associations and their properties, respecting the following format: ASSOC_Name1|PROP_Name1,ASSOC_Name1|PROP_Name2.

The negative form is also supported [>=3.1]:

  • lists=!bcpg:activityList
  • fields=!cm:created,!bcpg:nutListRoundedValue,!cm:modifier,!cm:creator,!cm:modifier,!cm:modified,!bcpg:entityScore,!bcpg:formulatedDate,!bcpg:illLogValue

Finally, for the JSON format, the params parameter passes certain parameters to the API [>=3.1]:

  • appendCode (true): Disables the addition of the beCPG code
  • appendErpCode (true): Disables the addition of the ERP code
  • appendMlTextConstraint (true): Disables the addition of multilingual constraints
  • appendNodeRef (true): Disables the addition of the ID
  • appendMlText (true): Disables the addition of multilingual values [>=3.2]
  • appendContent (false): Includes the file contents in the JSON

This parameter is in JSON format:

params = {
         "appendCode": true,
         "appendErpCode": false
         }

It must be encoded in the request:

params=%7B%22appendCode%22%3Afalse%2C%22appendMlTextConstraint%22%3Afalse%2C%22appendContent%22%3Atrue%7D

You can also specify parameters in the URL using jsonParam as a prefix [>=3.3]:

?jsonParamAppendCode=true&jsonParamAppendErpCode=false...

Example:

http://localhost/alfresco/service/becpg/remote/entity?nodeRef=workspace://SpacesStore/9b4dd09a-afaa-41ec-84eb-db062146975c&fields=bcpg:legalName,bcpg:clients,bcpg:compoListProduct|bcpg:productState&lists= bcpg:compoList

Get insights via report API

<url>/becpg/report/datasource?nodeRef={nodeRef}</url>

The report API processes the data and makes the XML easier to use. The formulation data, tare, cost and multi-level lists are directly usable. This API is recommended to extract product data.

Please note that this API is slower.

This API accepts the locale parameter used to specify the language of the data, as well as the reportParams object passed in the POST content of the request.

Below is an example of reportParams. See the report documentation for more details on the parameters: Extractor - Part 1:

  {
   iterationKey: "bcpg:compoList",
   params: [{
     id: "param1",
     prop: "bcpg:compoListProduct|cm:name",
     // Values
     nodeRef: dataListNodeRef
     value: productName
   }],
   prefs: {
    extractInMultiLevel: "true",
    componentDatalistsToExtract: "",
    extractPriceBreaks: "true",
    mlTextFields: "cm:title",
    assocsToExtract: "bcpg:plants,bcpg:suppliers,bcpg:storageConditionsRef,bcpg:precautionOfUseRef,bcpg:nutListNut",
    assocsToExtractWithDataList: "",
    assocsToExtractWithImage : "bcpg:clients",
    multilineProperties:"bcpg:organoListValue"
   }
   nameFormat: "{entity_cm:name} - {report_cm:name} - {locale} - {param1}",
   titleFormat: "{report_cm:name} - {locale} - {param1}"

  }

Check that an entity exists

You can check whether an entity exists using the following URL:

<url>/becpg/remote/check?nodeRef={nodeRef}&format={format}</url>

If the entity exists, the response is "OK". If it does not exist, the response is "KO".

Get or share a document

To get or share a document, use the following GET request:

<url>/becpg/remote/entity/content?nodeRef={nodeRef}&share={?true/false}</url>

If the "share" parameter is set to "true", the request shares the document and returns the share URL. If the parameter is "false" or missing, the request returns the document content.

Get model information

To get the description of the fields of an entity type, use the following URL:

<url>/becpg/remote/entity/dictionary?type={type}&format={json_schema/xsd}&fields={fields}</url>

The type parameter specifies the type of object to describe, for example: type=bcpg:finishedProduct. Note that this parameter is used only for the JSON format and has no effect for XSD formats.

The format parameter specifies the response format. The available options are:

  • format=json_schema: JSON validation schema.
  • format=xsd: XSD format (XML Schema Definition).
  • format=xsd_excel: XSD format for Excel.

You can also use additional filtering parameters to lighten the response:

  • Properties Filtering: includes only the listed properties. For example, to keep only the bcpg:legalName property, use: fields=bcpg:legalName.

Update an entity

To create or update an entity, use the PUT (Create) and POST (Update) methods with the following queries:

<url>/becpg/remote/entity?nodeRef={nodeRef}</url>
<url>/becpg/remote/entity?query={query}</url>
<url>/becpg/remote/entity?nodeRef={nodeRef}&createVersion=true&majorVersion={majorVersion}&versionDescription={description}</url>

The request body must contain XML or JSON in the default format of the remote API. You do not need to provide all the fields: only the fields present are created/updated.

When createVersion=true, majorVersion (true/false) and versionDescription create a new version of the entity to update. [>=2.1]

Use the ~ symbol to indicate a path relative to the imported entity.

Example

Example cURL request to create an entity:

curl --user username:password -H "Content-Type: application/xml" -X PUT --data @sample-entity.xml http://localhost/alfresco/service/becpg/remote/entity

Sample XML to create a project (sample-entity.xml):

<?xml version='1.0' encoding='UTF-8'?>
<pjt:project xmlns:pjt="http://www.bcpg.fr/model/project/1.0" path="/app:company_home/st:sites/cm:simulation/cm:documentLibrary"
type="node" name="Sample project">
<pjt:projectPriority type="d:int"><![CDATA[2]]></pjt:projectPriority>
    <cm:description xmlns:cm="http://www.alfresco.org/model/content/1.0" type="d:mltext" fr="Texte - texte -texte"><![CDATA[Texte - texte -texte]]></cm:description>
<cm:name xmlns:cm="http://www.alfresco.org/model/content/1.0" type="d:text"><![CDATA[Sample project]]></cm:name>
    <cm:title xmlns:cm="http://www.alfresco.org/model/content/1.0" type="d:mltext" fr="Sample project"><![CDATA[Sample project]]></cm:title>
<pjt:projectState type="d:text"><![CDATA[Planned]]></pjt:projectState>
</pjt:project>

You can also use the JSON format, which is the recommended format for creation and update since version 3.0 of the API. This format makes it possible to update some fields that could not be updated before.

curl --user username:password -H "Content-Type: application/json" -X PUT --data @sample-json.json http://localhost/alfresco/service/becpg/remote/entity?format=json

For each element, the root defines the keys used to search for the element, and attributes specifies the values to update.

Example:

{
     "entity": {
         "bcpg:erpCode": "TEST-REMOTE001",
         "cm:name":"Test remote",
         "type": "bcpg:finishedProduct",
        "params" : {
         "replaceExistingLists": true,
         "dataListsToReplace": "bcpg:allergenList,bcpg:compoList"
         },
         "attributes": {
                 "bcpg:legalName_en": "Legal Produit fini EN",
                 "bcpg:legalName": "Legal Produit fini FR",
                 "bcpg:clients": [
                         {
                             "bcpg:code": "C1"
                         },
                         {
                             "bcpg:code": "C2"
                         }
                     ],

                   "bcpg:productHierarchy2": {
"path": "/app:company_home/cm:System/cm:ProductHierarchy/bcpg:entityLists/cm:finishedProduct_Hierarchy",
"bcpg:lkvValue": "Pizza",
"type": "bcpg:linkedValue"
}
             },
         "datalists": {
           "bcpg:allergenList": [
                 {
                 "bcpg:allergenListAllergen": {
                          "bcpg:charactName": "Allergen 4"
                     },
                     "attributes": {
                         "bcpg:allergenListVoluntary": false,
                         "bcpg:allergenListInVoluntary": true
                     },
                     "type": "bcpg:allergenList"
                 }
             ],
           "bcpg:compoList": [
                 {
                  "bcpg:compoListProduct": {
                             "bcpg:code": "LSF411"
                      },
                     "attributes": {
                         "bcpg:compoListQtySubFormula": 15,
                         "bcpg:compoListUnit": "kg"
                     }
                 },
                  {
                  "bcpg:compoListProduct": {
                             "bcpg:erpCode": "TEST1"
                      },
                     "attributes": {
                         "bcpg:compoListQtySubFormula": 10,
                         "bcpg:compoListUnit": "kg"
                     }
                 }
         ]
         }
     }
}

The params attribute passes certain parameters to the API:

  • replaceExistingLists (false): Deletes the list rows that are not present in the JSON file [>=3.0]
  • dataListsToReplace (""): Deletes rows in certain lists only [>=3.0]
  • failOnAssociationNotFound (true): Raises an error when an associated entity cannot be found. Set it to false to ignore associations that cannot be found [>=3.1]
  • ignorePathOnSearch (false): If the beCPG code or the ERP code is provided, ignores the path for the search [>=3.1]

Update a multi-language property

You can import mltext type fields by specifying the value for each language:

<cm:title xmlns:cm="http://www.alfresco.org/model/content/1.0" type="d:mltext" de="Beispielprojekt" fr="Exemple de projet" en="Sample project"><![CDATA[Sample project]]></cm:title>

In JSON, the property is followed by an underscore and the language code:

"bcpg:legalName_en_US": "US value"

Update an association

An association can be identified by its nodeRef, its name, its code (beCPG or ERP) and its path.

Note: in versions < 2.0, you must provide a dummy nodeRef.

Example: project entity association:

<pjt:projectEntity type="assoc"><bcpg:finishedProduct type="node" name="ENTITY_NAME" code="BCPG_CODE" nodeRef="FAKE_NODEREF"></bcpg:finishedProduct></pjt:projectEntity>

Delete an entity

The remote API deletes entities with the following DELETE requests:

 <url>/becpg/remote/entity?nodeRef={nodeRef}&format={format}</url>
 <url>/becpg/remote/entity?query={query}&format={format}</url>

Sample script to mass delete entities (all materials):

#!/bin/sh
export REMOTE_SERVER=http://localhost/alfresco/service/becpg/remote/entity
export REMOTE_USER=admin
echo "Enter password"
read REMOTE_PASSWORD

if [ $# -ne 1 ]
    then
                 #LIST
                 wget --quiet --http-user=$REMOTE_USER --http-password=$REMOTE_PASSWORD --header=Accept-Charset:iso-8859-1,utf-8 --header=Accept-Language:en-us -O list.xml $REMOTE_SERVER/list?query=%2BTYPE%3A%22bcpg%3ArawMaterial%22%20-ASPECT%3A%22sys%3Atemporary%22%20-ASPECT%3A%22bcpg%3AentityTplAspect%22
                 count=1

                 while [ -n "$nodeRef" -o $count = 1 ]
                 do
                    nodeRef=`cat list.xml | xpath -q -e //*[$count]/@nodeRef |sed s/nodeRef=//g|sed s/\"//g|sed s/\:\\\///g| xargs`

                  echo "DELETE ${nodeRef}";
                  curl --user $REMOTE_USER:$REMOTE_PASSWORD -X DELETE "$REMOTE_SERVER?nodeRef=$nodeRef"
                  count=$((count+1))
                 done

       exit 0
fi

Get a spec sheet

The remote API [>=2.0] also lets you download reports using the following GET methods:

 <url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}</url>
 <url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}&locale={locale}</url>
 <url>/becpg/remote/report?nodeRef={nodeRef}&tplNodeRef={tplNodeRef}&locale={locale}&format={format}</url>
  • nodeRef: the system identifier of the product
  • tplNodeRef: the identifier of the report template
  • locale: the language code
  • format: the report format (PDF, XLSX, DOCX, ODT, ZIP)

You can also download reports by passing the parameters in JSON format in a POST request.

Example using cURL:

     #!/bin/sh

     export LOCAL_SERVER=http://localhost/alfresco/service/becpg/remote/report
     export LOCAL_USER=admin
     export LOCAL_PASSWORD=becpg

     curl --user $LOCAL_USER:$LOCAL_PASSWORD -H "Content-Type: application/json" -X POST --data @params.json "$LOCAL_SERVER?nodeRef=$1&tplNodeRef=$2" > report.pdf

The variables $1 and $2 are respectively the identifier of the product and the identifier of the report template. The params.json file contains the parameters:

     {
     iterationKey: "bcpg:plant",
     params: [{
     id: "param1",
     prop: "cm:name"
     }],
     prefs: {
     assocsToExtract: "bcpg:plants,bcpg:suppliers,bcpg:storageConditionsRef,bcpg:precautionOfUseRef,bcpg:nutListNut",
     assocsToExtractWithDataList: "bcpg:compoListProduct"
     },
     nameFormat: "{entity_cm:name}-{report_cm:name}-{locale}-{param1}",
     titleFormat: " {report_cm:name} - {locale} - {param1}"
     }

For more details on report settings, see Extractor - Part 1.

Create and merge a branch

The following POST requests respectively create and merge a branch [>=V2.1]:

<url>/becpg/remote/branch?nodeRef={nodeRef}&destNodeRef={destNodeRef?}</url>

destNodeRef is optional. By default, the branch is created in the same folder as the entity.

<url>/becpg/remote/merge?nodeRef={nodeRef}&branchToNodeRef={branchToNodeRef?}&majorVersion={majorVersion?}&impactWused={impactWused?}</url>

Request body:

{
  "description":"Branch description"
}

Alfresco API

Alfresco also offers a REST API documented here:

https://docs.alfresco.com/content-services/latest/

You can browse it at this URL:

https://api-explorer.alfresco.com/api-explorer/

Retrieving users and groups

Alfresco provides APIs to retrieve users and their associated groups.

List users

Use the following endpoint to retrieve the list of users:

GET /alfresco/api/-default-/public/alfresco/versions/1/people

Get user groups

Use the following endpoint to retrieve the list of groups associated with a specific user:

GET /alfresco/api/-default-/public/alfresco/versions/1/people/{Id}/groups

Replace {Id} with the identifier of the user.

Appendix 1: Example queries

GET List Finished Product Sample

  curl --location --request GET 'https://$server/alfresco/service/becpg/remote/entity/list?query=+TYPE:"bcpg:finishedProduct"&format=json&fields=bcpg:legalName,bcpg:clients'

PARAMS

Parameter Value
query +TYPE:"bcpg:finishedProduct"
format json
fields bcpg:legalName,bcpg:clients

GET List of products by last modified Sample

curl --location --request GET 'https://$server/alfresco/service/becpg/remote/entity?format=json&query=(@cm\:created:[2020-02-10 TO MAX] OR @cm\ :modified:[2020-02-10 TO MAX]) AND ( TYPE:"bcpg:finishedProduct" OR TYPE:"bcpg:semiFinishedProduct")

PARAMS

Parameter Value
query (@cm\:created:[2020-02-10 TO MAX] OR @cm\:modified:[2020-02-10 TO MAX]) AND ( TYPE:"bcpg:finishedProduct" OR TYPE:"bcpg:semiFinishedProduct" )
format json

Get Entity allergen list Sample

   curl --location --request GET 'https://$server/alfresco/service/becpg/remote/entity?format=json&query=+@bcpg\:erpCode:"TEST1"&lists=bcpg:allergenList&fields=bcpg:allergenListAllergen| bcpg:allergenCode,bcpg:allergenListVoluntary,bcpg:allergenListInVoluntary'

PARAMS

Parameter Value
query @bcpg\:erpCode:"TEST1"
format json
lists bcpg:allergenList
fields bcpg:allergenListAllergen\ bcpg:allergenCode,bcpg:allergenListVoluntary,bcpg:allergenListInVoluntary

Get Compo List Sample

   curl --location --request GET 'https://$server/alfresco/service/becpg/remote/entity?format=json&query=+@bcpg\:erpCode:"TEST1"&lists=bcpg:compoList&fields=bcpg:compoListProduct, bcpg:compoListQtySubFormula,bcpg:compoListUnit'

PARAMS

Parameter Value
query @bcpg\:erpCode:"TEST1"
format json
lists bcpg:compoList
fields bcpg:compoListProduct,bcpg:compoListQtySubFormula,bcpg:compoListUnit

GET Get Entity

  curl --location --request GET 'https://$server/alfresco/service/becpg/remote/entity?format=json&query=+@bcpg\:erpCode:"TEST1"'

PARAMS

Parameter Value
query @bcpg\:erpCode:"TEST1"
format json

Appendix 2: Java Utility

beCPG also provides a Java utility library to make calls to REST services easier. This library can be compiled from source code:

https://github.com/becpg/becpg-java-rest-api

Below is an example that retrieves an entity and its geographical origins:

@Autowired
private EntityApi entityApi;

@Test
void testEntityApi() {        
    List<RemoteEntityRef> entities =  entityApi.list("+TYPE:\"bcpg:finishedProduct\" AND +bcpg\\:erpCode:\"PERF-PF1\"");
    for(RemoteEntityRef entityRef : entities) {
       RemoteEntity entity = entityApi.get(entityRef.getEntity().getId());

       Assert.assertNotNull(entity.getName());
       Assert.assertNotNull(entity.getAttributes());
       Assert.assertNotNull(entity.getDatalists());

       logger.info(entity.getAttributes().get("bcpg:entityTplRef").toString());

        List<RemoteNodeInfo> geoOrigins = entity.getAssociations("bcpg:productGeoOrigin");
        RemoteNodeInfo entityTpl =  entity.getAssociation("bcpg:entityTplRef");

        break;
    }
}

results matching ""

    No results matching ""