November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hi,
You can't post multiple prices at once. As the can see the function:
public virtual IHttpActionResult PostCatalogEntryPrice(string code, [FromBody]Price price)
So you need to post price one by one.
Regards,
/Q
Yes, we had encountered the same issue recently. The Price Restful resource made us feel it accepts the collection as well, and the errror message added more weight on this.
var result = client.PostAsync("/episerverapi/commerce/entries/{entry code}/prices", new StringContent ...
So the question is what do we benefit from price service api comparing to use price service directly? Apart from that, the price service api does not seem triggering the event, my variants price are not updated in Find.
Note that the ServiceApi works in a RESTFul model. To use the priceservice directly, you will need access to the context of the site. This does mean you will need to write code in your website to handle the import. And ServiceAPI does much more than just prices.
Got your point.
Note that here you are using IPriceDetailService, and the prices, after optimizations, might not be changed. In that case, the event will not be triggered and the Find index will not be updated.
Interesting, first time I heard this "optimizations". It would be good if you can give bit more information about this.
I think we are currently using the Price Service API to update the price, however it's not triggering the event as well. My current workround is to Enable Find Index Job interval, and let it run automatically.
Thanks,
Vincent
My statement above is, in fact, incorrect. Even if the optimized prices are not changed, the event will still be fired.
In your case, is ServiceAPI is running on same context with your main site? Are other changes (such as entry updates) made by ServiceAPI indexed by Find?
I have confirmed that I am able to post a new price thank you. I am now receiving an error using the Put Entry Price method (/episerverapi/commerce/entries/{entry code}/prices/{priceValueId}) My assumption is that this method updates the price specified. Is that correct? If not, is there a way to update prices?
Thanks.
Yes, PutCatalogEntryPrices should update the price - but what is the error you got?
405.0 - Method Not Allowed
Here's the function, Am I missing something?
var price = new Models.Catalog.Price () { PriceValueId= 6, CatalogEntryCode = entryCode, ApplicationId = _applicationId, MarketId = "DEFAULT", PriceTypeId = "AllCustomers", PriceCode = String.Empty, ValidFrom = DateTime.Now.AddDays(-1), ValidUntil = null, MinQuantity = Convert.ToDecimal(26), UnitPrice = Convert.ToDecimal(160.00), CurrencyCode = "USD" }
public Models.Catalog.Price UpdatePrice(Models.Catalog.Price price) { try { Models.Catalog.Price list = null; var messages = new JobMessage(); if (_token == null) _token = GetToken(_username, _password); using (var client = new HttpClient() { BaseAddress = new Uri(_baseAddress) }) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.AccessToken); var jsonModel = JsonConvert.SerializeObject(price); var response = client.PutAsync($"/episerverapi/commerce/entries/{price.CatalogEntryCode}/prices/{price.PriceValueId}", new StringContent(jsonModel, Encoding.UTF8, "application/json")).Result; var result = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { string json = string.Empty; using (StreamReader reader = new StreamReader(response.Content.ReadAsStreamAsync().Result)) { json = reader.ReadToEnd(); list = JsonConvert.DeserializeObject<Models.Catalog.Price>(json); } } else { messages = JsonConvert.DeserializeObject<JobMessage>(result); throw new ServiceException(messages); } } return list; } catch (Exception ex) { throw; } }
I'm not entirely sure but
client.PutAsync($"/episerverapi/commerce/entries/{price.CatalogEntryCode}/prices/{price.PriceValueId}"
Should be
client.PutAsync("/episerverapi/commerce/entries/{entry code}/prices/{priceValueId}"
and $ character should not be there?
/Q
Ah right - the C# 6 stuffs - I'm outdated now :)
What do you have in <system.webServer> - seems to me a configuration issue where PUT was not enabled.
PUT is there.
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="524288000" /> </requestFiltering> </security> <validation validateIntegratedModeConfiguration="false" /> <httpErrors errorMode="Detailed"> <remove statusCode="404" /> <remove statusCode="500" /> <error statusCode="404" path="/Views/ErrorHandling/ErrorHandler" responseMode="ExecuteURL" /> <error statusCode="500" path="/Views/ErrorHandling/ErrorHandler" responseMode="ExecuteURL" /> </httpErrors> <modules runAllManagedModulesForAllRequests="true"> <add name="InitializationModule" type="EPiServer.Framework.Initialization.InitializationModule, EPiServer.Framework" preCondition="managedHandler"/> <add name="UrlRewriteModule" type="EPiServer.Web.RoutingUrlRewriteModule, EPiServer" preCondition="managedHandler"/> <add name="ShellRoutingModule" type="EPiServer.Shell.Web.Routing.ShellRoutingModule, EPiServer.Shell"/> <add name="BusinessFoundationInitializeModule" preCondition="managedHandler" type="Mediachase.Commerce.Core.Modules.BusinessFoundationInitializeModule, Mediachase.Commerce"/> <add name="ProfileModule" type="EPiServer.Business.Commerce.HttpModules.ProfileModule, EPiServer.Business.Commerce"/> <add name="CatalogNodeModule" type="EPiServer.Business.Commerce.HttpModules.CatalogNodeModule, EPiServer.Business.Commerce"/> <add name="ErrorLog" type="EOCodeLibrary.Core.ErrorHandling.ErrorLogModule"/> <add name="MirroringMonitoringModule" type="EPiServer.MirroringService.MirroringMonitoring.MirroringMonitoringModule, EPiServer.Enterprise" preCondition="managedHandler" /> </modules> <handlers> <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <add name="ReportingHttpHandler" preCondition="integratedMode" path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </handlers> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" /> </staticContent> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> <add name="X-UA-Compatible" value="IE=edge" /> </customHeaders> </httpProtocol> </system.webServer>
<modules> <remove name="WebDAVModule"/> </modules> <handlers> <remove name="WebDAV" /> </handlers>
These seem to be missing.
/Q