What is the proper way to get a product using the Web Api (v3.2.1)? I thought it would be something like these but they don't work:
/odata/v1/Products(608)/
/odata/v1/Products(608)/Product
/odata/v1/Products/608
/odata/v1/GetProduct(608)
/odata/v1/Products/GetProduct(608)
/odata/v1/Products?Id=608
Not really sure what's going on, since these work:
/odata/v1/Products(608)/CountryOfOrigin
/odata/v1/Products(608)/DeliveryTime
/odata/v1/Products(567)/QuantityUnit
And these don't work (error 400):
/odata/v1/Products(608)/ProductManufacturers
/odata/v1/Products(608)/ProductCategories
/odata/v1/Products(567)/ProductVariantAttributeCombinations
/odata/v1/Products(608)/Manufacturers
/odata/v1/Products(608)/Categories
/odata/v1/Products(567)/VariantAttributeCombinations
Code:
string publicKey = "publicKey"; string secretKey = "secretKey"; string method = "get"; string accept = "application/json, text/javascript, text/html, application/xhtml+xml, application/xml;q=0.9,image/webp,image/apng,*/*"; string timestamp = DateTime.UtcNow.ToString("o"); string url = this.textBox1.Text; var uri = new Uri(url); // decode url if (uri.Query != null && uri.Query.Length > 0) { url = string.Concat(uri.GetLeftPart(UriPartial.Path), HttpUtility.UrlDecode(uri.Query)); } var messageRepresentation = string.Join("\n", method.ToLower(), "", accept.ToLower(), url.ToLower(), timestamp, publicKey.ToLower() ); var signature = CreateSignature(secretKey, messageRepresentation); var request = (HttpWebRequest)WebRequest.Create(url); request.Method = method; request.UserAgent = "My shopping data consumer v.1.0"; request.Accept = accept; request.Headers.Add("Accept-Charset", "UTF-8"); request.Headers.Add("SmartStore-Net-Api-PublicKey", publicKey); request.Headers.Add("SmartStore-Net-Api-Date", timestamp); request.Headers.Add("Authorization", "SmNetHmac1 " + signature); HttpWebResponse webResponse = null; string response = null; try { webResponse = request.GetResponse() as HttpWebResponse; using (var reader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8)) { response = reader.ReadToEnd(); } } catch (Exception ex) { this.textBox2.Text = ex.ToString(); } finally { if (webResponse != null) { this.textBox2.Text = response; webResponse.Close(); webResponse.Dispose(); } }