Comments (4)
You can use the CartSetCustomTypeAction:
this._projectApiRoot = serviceProviderFixture.GetService<ProjectApiRoot>();
await _projectApiRoot
.Carts()
.WithId("cartId")
.Post(new CartUpdate
{
Version = 1,
Actions =
{
new CartSetCustomTypeAction
{
Type =
{
Id = "abandonedFieldId"
},
Fields =
{
{ "id", "abandonedTag" }
}
}
}
})
.ExecuteAsync();
I would also suggest that you use the projectApiRoot to avoid injecting the projectKey at every request.
from commercetools-dotnet-core-sdk-v2.
Hello @jenschude
When I perform the query you suggest (with projectApiRoot or with the standard commerceToolsClient),
await _commerceToolsClient
.WithApi().WithProjectKey(_projectKey)
.Carts()
.WithId("bda0b57b-024a-4cde-98af-a43594ded4c8")
.Post(new CartUpdate
{
Version = 4,
Actions =
{
new CartSetCustomTypeAction
{
Type =
{
Id = "3259d348-441a-4067-b4dc-e5e8bedd6bfa"
},
Fields =
{
{ "cart_abandoned_tag", 2 }
}
}
}
})
.ExecuteAsync();
I get the error :
Exception thrown: 'System.NullReferenceException' in MyApp.dll: 'Object reference not set to an instance of an object.'
I suspect the Type
or Fields
properties to be the root cause, but I require your help again.
BWT : is using projectApiRoot instead commerceToolsClient is for DI convenience only ? I mean there is no impact on performance right ?
Thank you
from commercetools-dotnet-core-sdk-v2.
Ah sorry. My fault with to much juggling between languages:
await projectApiRoot
.Carts()
.WithId("bda0b57b-024a-4cde-98af-a43594ded4c8")
.Post(new CartUpdate
{
Version = 4,
Actions = new List<ICartUpdateAction>()
{
new CartSetCustomTypeAction
{
Type = new TypeResourceIdentifier()
{
Id = "3259d348-441a-4067-b4dc-e5e8bedd6bfa"
},
Fields = new FieldContainer()
{
{ "cart_abandoned_tag", 2 }
}
}
}
})
.ExecuteAsync();
The types should be correctly stated.
And yes the projectApiRoot is a convenience class. There should be no performance impact.
from commercetools-dotnet-core-sdk-v2.
Perfect it works like a charm, thank you
from commercetools-dotnet-core-sdk-v2.
Related Issues (20)
- CentPrecisionMoney conversion mismatch HOT 1
- Quotes: quoteState missing from IQuote in commercetools.Sdk.Api.Models.Quotes HOT 3
- MessageSubscription: Breaking change from 5.1 to 5.2? HOT 1
- Question about Serialization/Deserialization of messages HOT 8
- Custom timeouts and retries on HTTP Client HOT 2
- Issue Creating Cart with Custom Line Item with Line-Item Custom Field HOT 1
- No Blazor WASM support HOT 4
- Product exists HEAD call support HOT 1
- Image upload always missing content type HOT 1
- OOTB models in SDK not serializing properly HOT 9
- How to create a HTTP Subscription with Extension Destination HOT 1
- Use ISerializerService in Dependency Injection Setup HOT 5
- Commercetool HTTP Client not working with Single-file deployment
- Fix Security Vulnerability with System.Text.Encodings.Web HOT 2
- Bypass 409 concurrentmodificationexception and overwrite the resource HOT 1
- LineItems is null but it should not be null. Schema can be outdated HOT 2
- Unable to Add header with IClient HOT 6
- ProductProjectionPagedQueryResponse is Generated with a long Offset while the query only accepts a int32 offset. HOT 2
- Filter categories by subtree HOT 1
- BadRequest On FailedLogin (Wrong username/password) HOT 4
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 commercetools-dotnet-core-sdk-v2.