Contents
On this page
Import CSV - Plugixa Image Map
POST /plugixa-image-map/v1/csv/import
Make a new draft map from a CSV of hotspots, drawn on a picture from the Media Library.
Any signed-in user with both plugixa_image_map_import and plugixa_image_map_create. See Roles and permissions. Needs Plugixa Image Map Pro: on the free build this route does not exist and answers 404.
Request
POST https://your-site.example/wp-json/plugixa-image-map/v1/csv/import
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
csv |
string |
Yes | The file’s contents, in the format described in Preview CSV. |
image |
integer |
Yes | The attachment id of an image in the Media Library. |
title |
string |
No | The map’s title. Empty gives Imported hotspots. |
Rows that cannot be used are skipped and reported, and the rest are imported. Each hotspot gets an id such as spot-csv-1.
{
"csv": "name,x,y,tooltip,link,category\nReception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services\nCafe,70,30,,,Food\n",
"title": "Ground floor services",
"image": 58
}
Responses
201 Created. data describes the new map.
{
"success": true,
"data": {
"id": 24,
"count": 2,
"problems": []
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The new map’s id |
data.count |
integer |
Hotspots created |
data.problems[] |
array |
{ "line", "message" } for each row that was skipped |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_image_map_csv_image |
image is missing or not an image in the Media Library. |
413 |
plugixa_image_map_csv_too_large |
The CSV is over 1 MB. |
422 |
plugixa_image_map_csv_columns |
The first row has no x or no y column. |
422 |
plugixa_image_map_csv_empty |
No row could be used, so no map was made. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-image-map/v1/csv/import" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"csv":"name,x,y,tooltip,link,category\nReception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services\nCafe,70,30,,,Food\n","title":"Ground floor services","image":58}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-image-map/v1/csv/import');
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([
'csv' => 'name,x,y,tooltip,link,category
Reception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services
Cafe,70,30,,,Food
',
'title' => 'Ground floor services',
'image' => 58,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-image-map/v1/csv/import', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({
csv: 'name,x,y,tooltip,link,category
Reception,42.5,61.25,Open 8:00 to 18:00,https://your-site.example/visit,Services
Cafe,70,30,,,Food
',
title: 'Ground floor services',
image: 58,
}),
});
const { data } = await response.json();
Quick Links
Share