Contents
On this page
Run Import - Plugixa Testimonial
POST /plugixatestimonial/v1/import-export/import/execute
Import every row of a file uploaded with Upload Import File: step two of an import.
Administrators only: the user needs WordPress’s manage_options capability. No plugin capability opens this route.
Note.
mappingis keyed by column position ("0","1", …), not by name, althoughsuggested_mappingfrom step one is keyed by name. Convert it: a name key finds no value, and every row then fails with “Missing client name”.
Duplicates. A row is a duplicate when a testimonial with exactly the same name and text exists. With
overwrite, that testimonial is rebuilt from the row: unmapped fields are emptied,display_ordergoes back to0and its categories are replaced when the row has any.
Request
POST https://your-site.example/wp-json/plugixatestimonial/v1/import-export/import/execute
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
file_token |
string |
Yes | From Upload Import File. The file is deleted after this call, whatever the outcome. |
format |
string |
Yes | csv or json, as returned by Upload Import File. |
mapping |
object |
Yes | Column position to target field: client_name, client_role, client_company, testimonial_text, rating, video_url, website_url, status, is_featured, categories, lang (or language_code), translation_group, any custom field key, or _skip. |
options.default_status |
string |
No | Status for rows without a valid one. Defaults to pending. |
options.duplicate_handling |
string |
No | skip (the default) or overwrite. |
options.create_categories |
boolean |
No | Create categories named in the file that do not exist yet. Defaults to false: unknown names are dropped. |
Every row needs a name and a text, or it is reported in error_details. rating is clamped to 1 to 5 (default 5) and status must be pending, approved, rejected or draft. Categories are matched by exact name, comma-separated or as a JSON array. New rows get source import. With WPML or Polylang active, a row’s lang or language_code sets its language, and a translation_group is reused only when it is a real group id.
{
"file_token": "Qm7Xr2Lp9Tz4Vb8Nc3Kd6Wf1Hg5Js0Ya",
"format": "csv",
"mapping": {
"0": "client_name",
"1": "client_company",
"2": "testimonial_text",
"3": "rating"
},
"options": {
"default_status": "pending",
"duplicate_handling": "skip",
"create_categories": true
}
}
Responses
200 OK. The import ran.
{
"success": true,
"message": "1 testimonials imported successfully",
"data": {
"imported": 1,
"skipped": 1,
"errors": 0,
"error_details": [],
"created_categories": []
}
}
| Field | Type | Meaning |
|---|---|---|
data.imported |
integer |
Rows created or overwritten |
data.skipped |
integer |
Duplicates skipped |
data.errors |
integer |
Rows refused |
data.error_details |
object[] |
{ row, message } for the first 50, row counting the header as row 1 |
data.created_categories |
string[] |
Names of the categories it created |
message |
string |
A human-readable confirmation, translated to the site language |
Errors
| Status | Code | When |
|---|---|---|
400 |
rest_error |
“Missing required parameters”, “Invalid file token” or “Invalid format”. |
404 |
rest_error |
“Import file not found. Please upload again.”: the token is unknown or the file was already used. |
400 |
rest_error |
The file no longer parses: the same messages as Upload Import File. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixatestimonial/v1/import-export/import/execute" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"file_token":"Qm7Xr2Lp9Tz4Vb8Nc3Kd6Wf1Hg5Js0Ya","format":"csv","mapping":{"0":"client_name","1":"client_company","2":"testimonial_text","3":"rating"},"options":{"default_status":"pending","duplicate_handling":"skip","create_categories":true}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/import-export/import/execute');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'file_token' => 'Qm7Xr2Lp9Tz4Vb8Nc3Kd6Wf1Hg5Js0Ya',
'format' => 'csv',
'mapping' => [
'0' => 'client_name',
'1' => 'client_company',
'2' => 'testimonial_text',
'3' => 'rating',
],
'options' => [
'default_status' => 'pending',
'duplicate_handling' => 'skip',
'create_categories' => true,
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/import-export/import/execute', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ file_token: 'Qm7Xr2Lp9Tz4Vb8Nc3Kd6Wf1Hg5Js0Ya', format: 'csv', mapping: { '0': 'client_name', '1': 'client_company', '2': 'testimonial_text', '3': 'rating' }, options: { default_status: 'pending', duplicate_handling: 'skip', create_categories: true } }),
});
const { data } = await response.json();
Quick Links
Share