Profit REST Service GetConnector

A GetConnector retrieves data from a Profit environment. You can only call GetConnectors that have been activated in the app connector.

Contents

Available connectors

You view all GetConnectors and UpdateConnectors that are available for the Profit REST Services (these are the connectors that have been activated in the App connector).

To view available GetConnectors and UpdateConnectors:

  1. Call the Profit REST Services.
  2. Use the URL in /metainfo.
  3. Click on: GET.

    You see a list with all available connectors.

View GetConnector meta info

You get started with GetConnectors.

In practice, it may be useful to have the name, the description and all the fields of a GetConnector. In the field list, you see the field name, type, length, etc.

To view meta info:

  1. Call the Profit REST Services.
  2. Select a connector.
  3. Use the URL in /metainfo/get/.

Run a GetConnector (retrieve lines)

You run a GetConnector to retrieve lines (records) from Profit.

To run a GetConnector (retrieve lines):

In this example you retrieve all articles using the Profit_Article GetConnector.

  1. Call the Profit REST Services.
  2. Select the connector.
  3. Click on: GET.
  4. Use the URL in /connectors/{connectorid}.

  5. You can quickly switch to the JSON format.

Retrieve lines in batches

A GetConnector can retrieve a large number of records, despite of the use of filters. That is why we recommend to retrieve records in packages using the 'skip' and 'take' fields.

To retrieve lines in batches:

Call:

../ProfitRestServices/connectors/connectorname?skip=n&take=n

  • skip: the number of records to be skipped.
  • take: the number of records to be retrieved.

For each packet to be retrieved, you must make a separate call. Do this until you receive a packet that does not contain any more records.

Example:

You retrieve articles in packets of 10 lines.

Example:

../ProfitRestServices/connectors/Profit_Article?skip=0&take=10

../ProfitRestServices/connectors/Profit_Article?skip=10&take=10

../ProfitRestServices/connectors/Profit_Article?skip=20&take=10

etc.

Sort lines

Sort lines in ascending or descending order.

Sort lines in ascending order

Call:

../ProfitRestServices/connectors/Orderbyfieldids=Field1,Field2

Example:

You retrieve articles and sort them on description in ascending order.

../ProfitRestServices/connectors/Profit_Article?orderbyfieldids=Description

To sort lines in descending order:

Call:

../ProfitRestServices/connectors/Orderbyfieldids=-Field1,-Field2

Example:

You retrieve articles and sort them on description in descending order. Place a minus symbol before the sorting field.

../ProfitRestServices/connectors/Profit_Article?orderbyfieldids=-Description

Apply a filter (general explanation)

We strongly advise that you apply a filter when you run a GetConnector. This enhances performance and gives you only the records that you need.

If you always want to apply the same filter, include a fixed filter in the GetConnector in Profit. How to apply a filter in the call of the GetConnector is discussed below.

'Is equal to' filter on one value:

Call:

../ProfitRestServices/connectors/connectorname/field/filtervalue

Complete the call with the field and the filter value. This is an 'is equal to' filter.

Example:

You filter on debtor article code 1000.

../ProfitRestServices/connectors/Profit_Article/ItemCode/1000

To look up a field name:

When you build the REST connector, you can find the field name as follows.

  1. Run the following call:

    ../ProfitRestServices/connectors/Profit_Article

  2. You see all lines.
  3. Click on To JSON View.

  4. Include the key field and the value in the call:

    ../ProfitRestServices/connectors/Profit_Article/ItemCode/1000

In Profit, you see the field names in the properties of the GetConnector.

AND filter / OR filter

Explanation of filtering on multiple values.

AND filter (is equal to a filter on multiple fields):

You filter on multiple fields using an 'is equal to' filter. Records must match all filter criteria.

Call:

../ProfitRestServices/connectors/connectorname?field1,field2&filtervalue1,filtervalue2

  • This is an 'is equal to' filter.
  • Use a comma as the separator between the fields and between the filter values.

    Example:

    You filter on articles that have been changed on 1 January 2017 AND that are not blocked.

    ../ProfitRestServices/connectors/Profit_Article?ModifiedDate,Blocked&2017-01-01T00.00.00,false

OR filter (is equal to a filter on multiple fields):

You filter on multiple fields using an 'is equal to' filter. Records must match at least one criterion.

Call:

../ProfitRestServices/connectors/connectorname?field1;field2&filtervalue1;filtervalue2

  • This is an 'is equal to' filter.
  • Use a semicolon as the separator between the fields and between the filter values.

    Example:

    You filter on articles of article group 100 OR articles of article type 1.

    ../ProfitRestServices/connectors/Profit_Article?ArtGroup;ItemTypeCode&100;1

Filter with filter criteria

Explanation of filtering with a filter criterion such as 'contains', 'greater than', smaller than', etc.

To filter on one field using filter criteria:

Call:

../ProfitRestServices/connectors/connectorname?filterfieldids=Field1&filtervalues=Filtervalue1&operatortypes=Type

Example:

You filter on articles that have the Acer brand name in the description. That is why you use operator type 6, which is the 'contains' type.

../ProfitRestServices/connectors/Profit_Article?filterfieldids=Description&filtervalues=Acer&operatortypes=6

Overview of filter criteria

AND filter with filter criteria:

You filter on multiple fields using filter criteria. Records must match all filter criteria.

Call:

../ProfitRestServices/connectors/connectorname?filterfieldids=Field1,Field2&filtervalues=Filtervalue1,Filtervalue2&operatortypes=Type1,Type2

  • Use a comma as the separator between the fields and between the filter values.

    Example:

    You filter on articles. The description contains the brandname Acer AND the sales price is lower than 100 euros.

    You need operator types 6 ('contains') and 5 ('smaller than').

    /ProfitRestServices/connectors/Profit_Article?filterfieldids=Description,SalesPrice&filtervalues=Acer,100&operatortypes=6,5

Overview of filter criteria

OR filter using filter criteria:

You filter on multiple fields using filter criteria. Records must at least match one criterion.

Call:

../ProfitRestServices/connectors/connectorname?filterfieldids=Field1;Field2&filtervalues=Filtervalue1;Filtervalue2&operatortypes=Type1;Type2

  • Use a semicolon as the separator between the fields and between the filter values.

    Example:

    You filter on articles. The description contains the brandname Acer OR the sales price is lower than 100 euros.

    You need operator types 6 ('contains') and 5 ('smaller than').

    /ProfitRestServices/connectors/Profit_Article?filterfieldids=Description;SalesPrice&filtervalues=Acer;100&operatortypes=6;5

Overview of filter criteria

Combination of an AND filter and an OR filter

You can also combine an AND/OR filter when executing a GetConnector.

This is explained with an example. You start with an XML filter that you convert to a JSON filter.

Filter to be used:

  • Employees who hold a position of Manager AND who live in Oxford
  • Employees who hold a position of Designer AND who live in Oxford

Create an XML filter:

  1. Start https://connect.afas.nl and sign on.
  2. Go to: SOAP/XML / GetConnectors.
  3. Click Fetch metainfo and select the GetConnector.
  4. Click Create Filter and enter the filter.

  5. Click Show XML and copy the entire filter to the clipboard.

Convert XML to a SOAP call:

  1. Go to SOAP/XML / XML to JSON and convert the filter to JSON.

  2. Copy the JSON code and 'encode' this to ASCII. This will ensure that you get code that can be used for a valid URL (without illegal characters). You can, for example, use https://ascii.cl/url-encoding.htm for this.

The result will look as follows:

%7B%0A%22Filters%22%3A+%7B%0A%22Filter%22%3A+%5B%0A%7B%0A%22@FilterId%22%3A+%22Filter+1%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Manager%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+2%22%2C%0A%22Field%22%3A+%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Docent%22%0A%7D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+3%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Ontwerper%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%0A%5D%0A%7D

Compile a URL:

The total UL call consists of the following components:

https://[deelnemersnummer].rest.afas.online/profitrestservices

+

/connectors/XXXXX?filterjson=

+

%7B%0A%22Filters%22%3A+%7B%0A%22Filter%22%3A+%5B%0A%7B%0A%22@FilterId%22%3A+%22Filter+1%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Manager%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+2%22%2C%0A%22Field%22%3A+%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Docent%22%0A%7D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+3%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Ontwerper%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%0A%5D%0A%7D

The entire URL:

https://[deelnemersnummer].rest.afas.online/profitrestservices/connectors/XXXXX?filterjson=%7B%0A%22Filters%22%3A+%7B%0A%22Filter%22%3A+%5B%0A%7B%0A%22@FilterId%22%3A+%22Filter+1%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Manager%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+2%22%2C%0A%22Field%22%3A+%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Docent%22%0A%7D%0A%7D%2C%0A%7B%0A%22@FilterId%22%3A+%22Filter+3%22%2C%0A%22Field%22%3A+%5B%0A%7B%0A%22@FieldId%22%3A+%22FunctionDesc%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%22Ontwerper%22%0A%7D%2C%0A%7B%0A%22@FieldId%22%3A+%22EmployerId%22%2C%0A%22@OperatorType%22%3A+%221%22%2C%0A%22%23text%22%3A+%2201%22%0A%7D%0A%5D%0A%7D%0A%5D%0A%7D

In this example, the URL of the new sign-on method is used.

Directly to

  1. Profit Rest Services (JSON)
  2. Call a connector using the Profit REST Service
  3. Add an app connector for the Profit REST Service
  4. Generate a token for the Profit REST Service
  5. Convert XML to JSON
  6. Call a GetConnector
  7. Call an UpdateConnector
  8. Call a ReportConnector
  9. Call a SubjectConnector
  10. Call a ProfitVersionConnector