Importing Data

The API allows updating stored fields using POST call parameters.

To be able to import/insert data through API requests, it is necessary to configure an Import Connector.

 

Data structure

“input_data” = [
    “{table name}” *** = [
        [
            “REF” = “{Unique register reference}”
            “{field name}” = “{new field value}”,
            “{field name}” = “{new field value}”,
            ...
        ],
        [ … ]
    ],
    “{other table name}” = [
        ...
    ]
]

Note: Importing via JSON will accept up to 50,000 items per call.

It is also possible to perform the import from a CSV, as shown below:

Example:

{“input_data”:{
    “products”:”http://externaldomain.com/download/product_items.csv”,
    …

From the API version 1.18 onwards, it is possible to specify an FTP access when importing a CSV file:

{“input_data”:{
	“products”: [
		“URL”:”ftps://externaldomain.com/download/product_items.csv”,
		“user”: “FTP_user”,
		“password”: “FTP_password”,
		“port”: “FTP_port”
	],
	…

Attention: The FTP must have a certificate signed by a certification authority, as a security standard in applications. Self-signed certificates will not be accepted. 

 

Other parameters:

Parameter

Value

Explanation

get_output_data

0 or 1

If we insert new data, no updated information is returned, unless explicitly requested.

get_affected_ids

0 or 1

It returns in the response the total number of items affected per table:"items_affected":{"products":5}

To view the details of new, modified, and deleted items, it is necessary to call the corresponding function using the SDK:

  • Call to the function: $SLConn->get_input_results()
  • The response: Array ( [items_affected] => 7 [new_items] => 2 [updated_items] => 2 [deleted_items] => 3 ) 

Basic configuration

The field names will be those defined in the connector under the Import Name section.
If a Table Alias is defined, it must be respected when defining the data to be imported in an HTTP POST request.

The configuration of the “Only update existing items” parameter will refer to:

  • Yes: only the items that already exist in the PIM will be updated, discarding all references detected as new in the import file.
  • No: it will allow the creation of new items in the PIM, as well as their update.

Item deletion using POST

To be able to delete data through a POST request, the most recommended way is to send the item status with the value X and map the field in the connector as in the following example:

“input_data” = [

	“products” = [

		[
			”product_reference” = “...”
			“status” = “X”
		],
		…
	]
]

Using version 1.18 of the API, it is possible to delete records by creating a new structure called delete_data, and sending it in the body of the POST request.

“delete_data” = [

	“{nombre tabla}” = [

		[
			“REF” = “{ref}”
		],
		…
	],
	...
]

Response and errors

The response to the data update request will arrive within the JSON/XML parameter “input_response”.

Its structure will be as follows:

“input_response” = [
    “result”= (0 = no changes, 1 = update done, 2 = update denied)
    “errors” = [
        0 = “error description”,
        {n} = …
    ],
    “items_affected” = [
        “{table}” = {number of modified fields},
    ]
]