sevenspikes / api-plugin-for-nopcommerce Goto Github PK
View Code? Open in Web Editor NEWAPI plugin for nopCommerce
License: MIT License
API plugin for nopCommerce
License: MIT License
Is there a way to pull products by store? I know that we can utilize the VendorName but in my situation one vendor may have products across multiple stores.
Currently the images are returned in Base64 format but this makes the response size quite heavy.
We need to create a setting to rerun the images with just a link to them.
We will use the src property instead of the attachment one.
We should validate the customer information when creating new customers or update existing ones.
For example:
If there is already a customer with a given email in the system we should not allow other customers to have the same email.
When the plugin is installed you should check if this is set to true. Otherwise in the administration the plugin is installed, but it is not working.
Not sure if I am missing something but I am having issues getting the Sample Application to work with this plugin.
Here's the steps I followed...
http://[removed.intentionally.com]/oauth/authorize?client_id=ed00f1bc-412f-4b7c-bdc6-2263c05ae810&redirect_uri=http%3a%2f%2flocalhost%3a49676%2ftoken&response_type=code&state=62965a9d-bcd6-40b1-80c0-07d3f941772a
If I try to hit any of the endpoints such as /api/customers/count I receive the same "Page Not Found" error.
I don't think I am having any issues on the Sample Application side because it never receives valid authorization information from the API.
I dug through the code on the API side and I noticed the configuration method on the Startup class is never called which means the public facing routes are never loaded.
Am I missing something?
And thanks, If I can get this project to work, it will save me a ton of development time!
Thanks for the fantastic plugin!
How do we validate a user on a mobile app client (say with userid & pwd, or fb, or google auth) against nop database using this plugin?
As far as I understand, the token is received after validating the client ID and secret, but that's not necessarily the user authentication. How do we get the access token for a specific user after authentication?
Am I missing something? Kindly help.
Pranay.
Now that my previous issue ( #35 ) has been resolved the plugin is working fine! Thanks!
Except for one thing: I tried to update the tax category id via the json property tax_category_id and nothing was updated. Now I checked the ProductDTO and there is the is_tax_exempt property, but the tax_category_id is missing.
Do I have to populate the tax category differently or is this really missing?
Thanks in advance!
Is there some documentation on how to expand the Swagger to include more functions?
I'm mimicking how categories is done, but the changes are not showing up on swagger/ui/index. I'm trying to expand to work with specification attributes.
Thank you.
Can anyone help with this? I'm not sure at this point what I'm missing.
Missing type map configuration or unsupported mapping.
Mapping types:
SpecificationAttribute -> SpecificationAttributeDto
Nop.Core.Domain.Catalog.SpecificationAttribute -> Nop.Plugin.Api.DTOs.SpecificationAttributes.SpecificationAttributeDto
I've also tried pushing the id, name and display order into a BaseSpecificationAttributeDto class, but that hasn't worked either.
I really appreciate your help and thanks for your time.
System.NullReferenceException: Object reference not set to an instance of an object. at Nop.Plugin.Api.Attributes.GetRequestsErrorInterceptorActionFilter.OnActionExecuted
this happens if an exception is thrown in any of the Controller's actions i.e add throw new Exception() in the CustomersController's GetCustomers method.
I would like to create vendors using Restful API and then link vendor and customer. Do you have plans to include that funcionality? It's a great plugin really.
Hi everyone,
started to use this project yesterday and got the authentication and product get methods working just fine. But now I am stuck on the post method.
I figured out issues with the json on my client applications end, which are now resolved, the json body of the post looks as follows:
{
"product": {
"product_type": "SimpleProduct",
"name": "Item Name",
"vendor_id":2,
"meta_title": "Item Name",
sku": "12300006",
"manufacturer_part_number":"123213",
"gtin": "4052792117541",
"stock_quantity": 0,
"price": "3.52",
"weight": "0.044",
"length": "0.087",
"width": "0.025",
"height": "0.18"
}
}
But now that I have resolved these issues I am running into issues on the server side. The post results into the following error:
3.52 is not a valid decimal value.
The corresponding stack trace:
System.Exception: 3.52 ist kein gültiger Wert für Decimal. ---> System.FormatException: Die Eingabezeichenfolge hat das falsche Format. bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) bei System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) bei System.ComponentModel.DecimalConverter.FromString(String value, NumberFormatInfo formatInfo) bei System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) --- Ende der internen Ausnahmestapelüberwachung --- bei System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) bei System.ComponentModel.NullableConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) bei Nop.Plugin.Api.Helpers.MappingHelper.ConvertAndSetValueIfValid(Object objectToBeUpdated, PropertyInfo objectProperty, Object propertyValue) bei Nop.Plugin.Api.Helpers.MappingHelper.SetValue(Object objectToBeUpdated, KeyValuePair`2 jsonPropertyValuePaires) bei Nop.Plugin.Api.Helpers.MappingHelper.SetValues(Dictionary`2 jsonPropertiesValuePairsPassed, Object objectToBeUpdated, Type propertyType) bei Nop.Plugin.Api.Delta.Delta`1..ctor(Dictionary`2 passedChangedJsonPropertyValuePaires) bei Nop.Plugin.Api.ModelBinders.JsonModelBinder`1.BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) bei System.Web.Http.ModelBinding.ModelBinderParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken) bei System.Web.Http.Controllers.HttpActionBinding.<ExecuteBindingAsyncCore>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
The nopCommerce instance is running on a Azure App Service. Seems like this is running in a German environment, so I tried to force a US environment:
Web.config:
<globalization culture="en-US" uiCulture="auto" />
Sadly without any effect. Suggestions on how to fix this would be highly appreciated!
Best regards!
I'm having trouble getting the customer addresses to update correctly when I do a POST to add customers to the database. The addresses appear in the database, but the CustomerAddresses table does not get populated. Can anyone tell me where the error is.
Here is the json:
{
"customer":{
"password":"*******",
"username":"[email protected]",
"email":"[email protected]",
"company":"Service One NY",
"first_name":"Loay",
"last_name":"Miller",
"role_ids":[
3
],
"admin_comment":"Account# 0000287",
"sage-customer-id":"0000287",
"billing_address":{
"first_name":"Loay",
"last_name":"Miller",
"email":"[email protected]",
"company":"Service One NY",
"country_id":1,
"country":"United States",
"state_province_id":58,
"city":"Twin Falls",
"address1":"1000 East Main",
"address2":"",
"zip_postal_code":"12345",
"phone_number":"(216) 553-3301",
"fax_number":"",
"province":"NY"
},
"shipping_address":{
"first_name":"Loay",
"last_name":"Miller",
"email":"[email protected]",
"company":"Service One NY",
"country_id":1,
"country":"United States",
"state_province_id":38,
"city":"Twin Falls",
"address1":"1000 East Main",
"address2":"",
"zip_postal_code":"12345",
"phone_number":"(216) 553-3301",
"fax_number":"",
"province":"NY"
}
}
}
Hi Can you please tell the process of posting data through api . I am trying to post customer data through api.
one more problem is there not able to login with admin credentials .
please let me know how to login to api
Hi, when I try to get the orders list by using customer id and if a particular customer have more then around 35 order then the application throw an exception as in the Issue title. However when I increase the timeout time to 10 minutes then I got the response. My question is, is it normal or there is a way to fix it. Thanks in advance.
I'm testing this wonderful plugin for a few days now, and everything seems quite ok as far as fetching data is concerned. However, when I try to POST a new product the API returns this error:
{ "errors": { "server_error": [ "Please contact the store owner!" ] } }
Any help would be appreciated.
I am looking for reading/updating inventory information.
The idea is to update the inventory of products on nopCommerce from our store/warehouse inventory system.
Product inventory update for products with track inventory & track inventory with product attributes.
I understand this solution is free, but I'm curious if it's been released under any particular license? GPL or otherwise.
Many Thanks!
Bryan
For example the CustomerDto class has a property:
[JsonProperty("created_on_utc")]
public DateTime? CreatedOnUtc { get; set; }
If we want to order the customers by their created date we should do it like this:
/api/customers/search?order=Created_On_Utc&query=company%3ANop%20Solutions%20Ltd&fields=Created_On_Utc
But now it works only if you specify the actual property name, which is not correct:
/api/customers/search?order=CreatedOnUtc&query=company%3ANop%20Solutions%20Ltd&fields=Created_On_Utc
So we should expect the order parameter to be the JSON property name (Created_On_Utc) and convert it internally to the actual property CreatedOnUtc.
Hi,
we had an issue with decimal types and their validation. We always got "Invalid Type Property" for e.g. the ProductPrice.
After a long time of investigation, we found the solution:
Because the webserver is culture "de-de" and in the validation there is only a call ".ToString()" the value "28.34" is then "28,34" and this value could not be validated as decimal
So we changed in class "TypeValidator" line 113 from
valueToValidate = value.ToString();
to
valueToValidate = string.Format(CultureInfo.InvariantCulture, "{0}", value);
This change worked for us. Maybe there is a better way to fix it.
Regards
Torsten
Hello
since use are exposing swagger (I suppose through swashbuckle) you might consider Autorest from Microsoft it is the tech behind the Add Rest Service in Visual studio. It can generate fully typed clients by consuming the swagger url. No need to write the client code yourself anymore.
we use it in the build process to generate clients for all our Web API projects. Also an added plus is you can also generate clients for Go, Java, Nodejs, Ruby with the flick of a command line parameter.
have a look at https://github.com/Azure/autorest/blob/master/Documentation/cli.md for more information
Hi Poyker,
Sorry, I just commented on the wrong page. As requested creating a new issue and hope it is fine.
I have a query with regards to creating an order, I am trying to create an order for products which have ProductAttribute and they are mandatory to add items to cart.
Could you please help me how can I generate attributesXml which must be passed from "AddOrderItemsToCart" to shoppingCartService.AddToCart ? at the moment you are passing null which is failing in creating an order as it returns the validation errors.
Hping for your expert help & advice..
Many Thanks,
Cimran
Hi,
I've been testing this plugin for the purposes of integrating my online application with NopCommerce websites. A specific task I've had a problem with is creating a product which contains child objects like a product picture as an example. When the plugin is used to create a product (including a product picture) I get returned the created product with its new id and a list of product pictures via a list of ImageDto's. The ImageDto's include their newly created ids. The problem is I don't have any way to tie these ids back to the images from my online system. A common approach would be to pass a correlation id with each object via the api call and have this correlation id passed back alongside the newly created id representing the id of the new object in the NopCommerce system.
This is an issue for all the child associations for ProductDto:
private List<int> _storeIds;
private List<int> _discountIds;
private List<int> _roleIds;
private List<int> _manufacturerIds;
private List<ImageDto> _images;
private List<int> _associatedProductIds;
private List<string> _tags;
Has this use case been considered?
Alain
From an admin site automation standpoint, it would be nice if we could perform CRUD operations on shipments.
I was trying to create shoppingCartItem for product with Attribute.
shopping_cart_item: {
customer_id: "1",
product_id: "24",
quantity: "1",
size: "8",
cartType: "ShoppingCart"
}
I get ERROR Please select Size
How can I pass attribute size to API ?
I go to your source code, to createShoppingCartItem and what I see...
var products_json = new { product = new
{
name = "test product api hello through short new new3",
full_description = "hello this is test1111",
short_description ="this is hello",
image = new
{
src = "http://cdn.lib-tech.com/wp-content/uploads/2016/07/2016-2017-Lib-Tech-Skate-Banana-Yellow-Snowboard-800x800.png"
}
}
};
string serializejsonproduct = JsonConvert.SerializeObject(products_json, Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
try
{
nopApiClient.Post(jsonUrl, serializejsonproduct);
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
when trying to add product with images it add product but not picture
Hi there. I'm trying to get the plugin to compile. I've made no code changes however, it doesn't seem to matter what references I add I can't get past this error. It will compile, but when I try to run it through the debugger I fail on this error. What am I doing wrong?
Details:
Framework: 4.5.1
VS2017
Solution does build when selecting "rebuild"
Any guidance would be greatly appreciated. Thank you!
at line 58, var elementsType = propertyType.GetGenericTypeDefinition();
it should be "var elementsType = propertyType.GetGenericArguments()[0];"
isCurrentPropertyValid = ValidateNestedProperty(propertyType, (Dictionary<string, object>) pair.Value);
}
// This case hadles collections.
else if (pair.Value != null && pair.Value is ICollection<object> &&
propertyType.GetInterface("IEnumerable") != null)
{
//var elementsType = propertyType.GetGenericTypeDefinition();
var elementsType = propertyType.GetGenericArguments()[0];
ICollection<object> propertyValueAsCollection = pair.Value as ICollection<object>;
// Validate the collection items.
foreach (var item in propertyValueAsCollection)
{
isCurrentPropertyValid = IsCurrentPropertyValid(elementsType, item);
if(!isCurrentPropertyValid) break;
}
}
/api/customers
We sort the customers by Id but since the CustomerDTO.Id is a string, they are ordered alphabetically rather than as numbers.
Hi I am new to nopcommerce. How can I install the plugin to nopcommerce, and does it support version 3.90
I am writing a WinForms app to run on an office PC to allow office staff to integrate with nopCommerce (orders, customers, products, etc.) For example, a customer calls to place an order - a popup window allows the office staff to enter a new order directly into nopCommerce.
I installed this plugin and wrote a little test app to authorize and issue some basic GETs to see it in action. It works just fine.
Now I am wondering, it seems like I have two choices for performing CRUD operations against my nopCommerce database:
Are there any advantages to using REST vs. just talking direct to the database?
I'm new to REST and I can see the benefit for other platforms (e.g. Mobile devices). But is it worth implementing in a traditional WinForms environment? Or would I just be better off using SQL Server?
We need to be able to associate a product with its grouped product
hi dear friend
when i request in postman (chrome extension for rest full request) require username and password and when i enter the email and password of admin it says wrong ...
what should i do ?
tnx
Hi,
When I try to add a product via a POST call to the plugin I get a validation error when the VendorId is zero.
This occurs because there is validation attribute [ValidateVendor] attached to the VendorId property of the ProductDto class. This is obviously by design, but it does not seem to match the rules of the NopCommerce site. Within the site you can create and edit a product with Vendor set to none which equates to a zero id.
I altered the ValidateVendor's Validate method to ignore the validation routine when a vendor id is zero to get around this error.
Have I got this rule wrong?
Alain
When deploying nopCommerce to IIS Core (Local Windows 10 or Windows Server 2008 R2) with this API plugin included I get OWIN errors on application startup. That does not happen in debug on local iis express. How can I solve this?
The following errors occurred while attempting to load the app.
Beschreibung: Unbehandelte Ausnahme beim Ausführen der aktuellen Webanforderung. Überprüfen Sie die Stapelüberwachung, um weitere Informationen über diesen Fehler anzuzeigen und festzustellen, wo der Fehler im Code verursacht wurde.
Ausnahmedetails: System.EntryPointNotFoundException: The following errors occurred while attempting to load the app.
Quellfehler:
Beim Ausführen der aktuellen Webanforderung wurde einen unbehandelte Ausnahme generiert. Informationen über den Ursprung und die Position der Ausnahme können mit der Ausnahmestapelüberwachung angezeigt werden.
Stapelüberwachung:
[EntryPointNotFoundException: The following errors occurred while attempting to load the app.
[HttpException (0x80004005): The following errors occurred while attempting to load the app.
Using "api/customers"
`### Create a new customer record
POST /api/customers
{
"customer": {
"first_name": "Steve",
"last_name": "Gates",
"email": "[email protected]",
"role_ids": [ 3 ]
}
}`
always return the response below
`{
"errors": {
"server_error": [
"Please contact the store owner!"
]
}
}`
Hi,
I've successfully got web hooks registering, triggering and calling back to the subscriber via the registered web hook Uri. I've got a couple more pieces of the puzzle to solve:
VerifyWebhook(string data, string hashedHeader, string webhookSecret)
Alain
Is it possible for the callback URL to be a web page hosted with the nopCommerce website that displays the authorization code?
This is how our application works with the Xero API: https://developer.xero.com/documentation/auth-and-limits/public-applications
Or instead of steps 1,2 and 3
Open Request Authorization Code URL: https://nopsite.com/oauth/authorize?client_id=xxx&client_secret=xxx
Nopcommerce 3.90
From the side menu I select "API">settings
Error:
The controller for path '/Plugins/ApiAdmin/Settings' was not found or does not implement IController.
What am I doing wrong here?
Thank you.
hi, I wanted to know if this version is compatible with version 3.90 nop commerce, and if not, soon plan to develop a version that is compatible? thank you
I'm getting an error (Invalid object name 'WebHooks.WebHooks') when trying to fetch the registered web hooks. I expected to get an empty result. The error occurs within the GetAllWebHooks controller action when executing:
IEnumerable<WebHook> webHooks = await _store.GetAllWebHooksAsync(userId);
I have successfully fetched web hook filters via the GetWebHookFilters() controller action so I know I'm communicating correctly with the plugin.
I'm new to web hooks, but I believe the issue occurs because the storage of these web hooks has not been configured correctly. The function ConfigureWebhooks(HttpConfiguration config) via Startup.cs appears to do this role. I cannot seem to find out how it fetches the required configuration information to do it's job.
Can you provide some insight into how this should be setup?
Add support for WebHooks.
A lot of services rely on WebHooks to be notified when something is changed in nopCommerce i.e Order Updated, Order Deleted etc.
We can use ASP.NET WebHooks
https://blogs.msdn.microsoft.com/webdev/2016/12/14/introducing-microsoft-asp-net-webhooks-preview-2/
Is it possible to map ProductAttributes via API?
hi dear friend
how to request to api by android ? how to solve callback url ?
tnx
Unable to reference AutoMapper dll and it is not available in packages.config file. I am getting 18 errors related to automapper. Which version of Automapper is used for this plugin?
If you want to access items from an order your should use api/order//items and not api/order//order_items => why specify order_items when the parent entity you are querying though is already an Order. Logic provides that the items will be order items. It is the same as saying I have an Order class with properties like OrderId, OrderDate, OrderItems and so on... No those properties should be Id, Date, Items really no need for repeating/prefixen the "Order".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.