REST usage notes
You might encounter the following issues when using REST endpoints.
Duplicate parameters in an REST call
In a REST call, it is possible that a route variable contains one value while the request body contains a different value. Whenever this type of conflict occurs, Magento uses the value specified in the request body.
For example:
The REST URL to update a customer is PUT /V1/customers/:id
. If you specify an ID value of 1
in the URL (http://<host>/rest/<store_code>/V1/customers/1
), and a body of { "customer": { "id": 2, "attr": "value" }}
, the customer with ID of 2
will be modified.
This applies to all REST APIs where a parameter is passed in the URL. Any value specified in the URL with the same parameter name as in the request body is ignored.
Create a bundle product
The following sample code creates a bundle product. The price_type
attribute code defined in the custom_attributes
object is set to 1
to allow the product to have a fixed price.
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
"product":{
"sku":"box-of-watches",
"name":"Box of Watches",
"attribute_set_id":11,
"price":100,
"status":1,
"visibility":4,
"type_id":"bundle",
"extension_attributes":{
"website_ids":[
1,
2
],
"category_links":[
{
"position":0,
"category_id":"3"
},
{
"position":0,
"category_id":"6"
}
],
"bundle_product_options":[
{
"title":"Men's Watches",
"required":true,
"type":"radio",
"position":1,
"sku":"box-of-watches",
"product_links":[
{
"sku":"24-MG04",
"qty":50,
"position":2,
"is_default":false,
"price":0,
"price_type":0,
"can_change_quantity":0
},
{
"sku":"24-MG05",
"qty":50,
"position":4,
"is_default":false,
"price":0,
"price_type":0,
"can_change_quantity":0
}
]
},
{
"title":"Women's Watches",
"required":true,
"type":"radio",
"position":2,
"sku":"box-of-watches",
"product_links":[
{
"sku":"24-WG01",
"qty":50,
"position":1,
"is_default":false,
"price":0,
"price_type":0,
"can_change_quantity":0
},
{
"sku":"24-WG09",
"qty":50,
"position":2,
"is_default":false,
"price":0,
"price_type":0,
"can_change_quantity":0
}
]
}
]
},
"custom_attributes":[
{
"attribute_code":"price_type",
"value":"1"
},
{
"attribute_code":"price_view",
"value":"0"
},
{
"attribute_code":"required_options",
"value":"1"
},
{
"attribute_code":"has_options",
"value":"1"
},
{
"attribute_code":"meta_title",
"value":"watch-test"
},
{
"attribute_code":"sku_type",
"value":"1"
},
{
"attribute_code":"meta_description",
"value":"watch-test This is a box of watches!"
},
{
"attribute_code":"weight_type",
"value":"0"
},
{
"attribute_code":"category_ids",
"value":[
"3",
"6"
]
},
{
"attribute_code":"description",
"value":"<p>This is a box of watches!</p>"
},
{
"attribute_code":"short_description",
"value":"<p>A box of watches</p>"
}
]
}
}
Related topics