SisoRestApiBundle
Using the REST interface
For GET requests a token is not required.
| axios.get('/api/ezp/v2/siso-rest/basket')
.then(function (response) {
app.basketObject = response.data;
if(app.basketObject.Basket) {
.....
}
}
|
If you are using a PATCH request, a token is required. A Twig function provides the current token.
1
2
3
4
5
6
7
8
9
10
11
12 | var token = "{{ csrf_token('rest') }}";
axios.patch('/api/ezp/v2/siso-rest/basket/current/shippingmethod', {
"ShippingMethodData": {
"shippingMethod": app.shippingMethod
}
}, {
headers: {
'X-CSRF-Token': token,
'Content-Type': 'application/vnd.ez.api.ShippingMethodData+json',
'Accept': 'application/vnd.ez.api.Basket+json'
}
})
|
Error handling / responses
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 | {
"ValidationResponse": {
"_media-type": "application\/vnd.ez.api.ValidationResponse+json",
"messages": {
"Party": {
"_errors": [
{
"_code": 103,
"_message": "This address is already stored in your address book"
}
]
"PartyName": [
{
"Name": {
"_errors": [
{
"_code": 100,
"_message": "This value should not be blank."
}
]
}
}
],
"PostalAddress": {
"StreetName": {
"_errors": [
{
"_code": 100,
"_message": "This value should not be blank."
}
]
},
"CityName": {
"_errors": [
{
"_code": 100,
"_message": "This value should not be blank."
}
]
},
"PostalZone": {
"_errors": [
{
"_code": 100,
"_message": "This value should not be blank."
},
{
"_code": 101,
"_message": "\"\" is not a valid ZIP code. For valid ZIP code use following pattern \"1234\"."
}
]
}
},
"Contact": {
"ElectronicMail": {
"_errors": [
{
"_code": 100,
"_message": "This value should not be blank."
}
]
}
}
}
}
}
}
|
| {{ error_message([Party][PartyName][Name]) }}
|