The following code examples will allow you to update the name of the language for a particular locale on a website. This is used when you wish for the Language selector to use a different label on your site.
Things you will need
1. Domain name. When using the site API, any requests must be sent to http://{subdomain}.{tool-domain}/api.php/endpoint. e.g. http://demoapi.editortool.companyabc.com/api.php/login
Login
Before we can use the site API, we’ll need to log into the individual site. This can be done via either of the following API calls:
1. Site API (requires username and password)
POST http://demoapi.editortool.companyabc.com/api.php/login { "username": "apidemo", "password": "apidemo123" }
Response:
{ "sessionId": "{session ID}", "message": "Set as cookie value for site_session", "sessionName: "site_session" }
2. HAL API (requires a token)
POST https://hal.mono.net/api/v1/reseller/account/site { "userToken": "{your-token}", "command": "apiLogin", "siteId": {your site ID} }
Response:
{ "status": { "code": 200, "text": "", "timeStamp": "2017-08-21T12:21:31+00:00" }, "data": [ { "sessionName": "site_session", "sessionId": "{session ID}" } ] }
Both calls will yield a session ID in the format 35 character alphanumeric. In any future calls we make, we must include the header 'Cookie=site_session={session ID}'.
Get all existing locales
GET http://demoapi.v5demo01.monosolutions.com/api.php/website/locales
Response:
[ { "locales": [ { "id": "l5001", "name": "en", "label": "David", "dateformat": "d/m/Y", "title": "", "keywords": "", "description": "", "position": 0 } ] } ]
Update a locale name
We can use the locale ID from the previous request to perform a RESTful PATCH and update the locale's label.
PATCH http://demoapi.v5demo01.monosolutions.com/api.php/website/locales/l5001 { "label": "English" }
Response:
[]