Comments (11)
Hi @RazaMemon
Please note that the Images and the Tags are collections and also the names should be in plural.
The easiest way to see how your JSON should be structured is to make a GET request and see the returned JSON. I personally use Swagger when I want to quickly see the JSON format.
So instead of passing a single image object you need to pass a list of image objects.
from api-plugin-for-nopcommerce.
@poyker thanks alot.. just want to quickly check with you, i am also using swagger and it show images, i tried code like below for adding tags and images but both add product but not tags or images.
var product_json = new { product = new { name = "hello world product api", full_description = "description", short_description ="this is test", tags = new string[]{ "test","product","hello","world" } } };
var product_json = new { product = new { name = "hello world product api images", full_description = "description images", short_description ="this is test images", images = new { { display_order =1, src = "http://google.com/images.png”, attachment=“”, } } } };
both i tried and it added name, full_description, short_description in nopcommerce, but not either tag or image.
from api-plugin-for-nopcommerce.
Hi @RazaMemon
What is the JSON that is generated with your code?
It should be something like this:
{
"product" : {
"name": "product name",
"images": [
{
"src": "http://someimageurl"
}
],
"tags": [ "tag1", "tag2" ]
}
}
You can see the JSON after you serialize the object to JSON and before the actual POST request.
from api-plugin-for-nopcommerce.
from api-plugin-for-nopcommerce.
Could you please check what is the exact error in the System -> Log?
from api-plugin-for-nopcommerce.
Thanks @poyker for prompt replying, appreciate your help, i am getting this error in log
System.ArgumentException: Cannot create an instance of Nop.Plugin.Api.Validators.TypeValidator
1[System.Collections.Generic.List1[T]] because Type.ContainsGenericParameters is true. at System.RuntimeType.CreateInstanceCheckThis() at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Nop.Plugin.Api.Validators.TypeValidator
1.ValidateNestedProperty(Type propertyType, Dictionary2 value) at Nop.Plugin.Api.Validators.TypeValidator
1.IsCurrentPropertyValid(Type type, Object value) at Nop.Plugin.Api.Validators.TypeValidator1.IsValid(Dictionary
2 propertyValuePaires) at Nop.Plugin.Api.ModelBinders.JsonModelBinder1.ValidateValueTypes(ModelBindingContext bindingContext, Dictionary
2 propertyValuePaires) at Nop.Plugin.Api.ModelBinders.JsonModelBinder`1.BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) at System.Web.Http.ModelBinding.ModelBinderParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken) at System.Web.Http.Controllers.HttpActionBinding.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()
from api-plugin-for-nopcommerce.
Hi @RazaMemon
Do you use the latest version of the plugin? This looks like some old error I have seen when the product type is not specified but this was fixed.
from api-plugin-for-nopcommerce.
@poyker i am using latest version, see my description file, i download the today,
Group: Api FriendlyName: Api SystemName: Nop.Plugin.Api Version: 1.0 SupportedVersions: 3.90 Author: nopCommerce/nop-templates team DisplayOrder: 1 FileName: Nop.Plugin.Api.dll Description: This plugin provides a Restful Api for connecting to your store
from api-plugin-for-nopcommerce.
@RazaMemon It turned out there was a problem validating generic type collection that was introduced during the upgrade to 3.90. That is why none of the collection properties was working during post/put requests. It is now corrected with this commit 0507ba1
from api-plugin-for-nopcommerce.
@poyker i am still unable to add product with images getting error
System.NullReferenceException: Object reference not set to an instance of an object. at Nop.Plugin.Api.Controllers.ProductsController.UpdateProductPictures(Product entityToUpdate, List1 setPictures) at Nop.Plugin.Api.Controllers.ProductsController.CreateProduct(Delta
1 productDelta) at lambda_method(Closure , Object , Object[] ) at
from api-plugin-for-nopcommerce.
Thank you for reporting it! The picture service was not initialized. Already fixed.
from api-plugin-for-nopcommerce.
Related Issues (20)
- when we are expecting version 4.3? HOT 1
- When the 4.3 support will be ? Any date & time please HOT 2
- Enable email/password and token authentication
- No image details in product and category HOT 6
- getting 403 Forbidden HOT 5
- API for ProductSearch available?
- Some help for using Postman? HOT 1
- Product category
- What About splitting API Plugin in 2 ?
- API Plugin 4.20
- API List for API Plugin 4.2 HOT 1
- Add Shipments to the API HOT 1
- Missing NuGet Assembly on deployment
- ProductAttributeMappingDto - An item with the same key has already been added HOT 1
- Community Fork? HOT 1
- API for Nopcommerce 4.4 (.net 5) HOT 2
- Banner API
- TierPrices
- Forgot Password API
- Nop Translation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api-plugin-for-nopcommerce.