ShopifySharp
ShopifySharp copied to clipboard
Can't create gift cards
Hello, I was wondering if there was a trick to creating gift cards. What we have:
- Shopify Plus
- Read-Write access to Gift Cards Transactions
- Read-Write access to Gift Cards
Here is my attempt:
var gc = new GiftCard()
{
InitialValue = (decimal)amount,
Code = code,
};
try
{
var result = await _service.CreateAsync(gc);
if (result != null) gc = result;
}
catch (Exception e)
{
_logger.LogError("Failed to create new gift card {ID}", code);
}
Here is the exception always get: Object reference not set to an instance of an object.
Stack Trace
at ShopifySharp.Infrastructure.Serializer.DeserializeWithNewtonsoft[T](String json, String rootElementPath, Nullable`1 dateParseHandlingOverride)
at ShopifySharp.Infrastructure.Serializer.Deserialize[T](String json, String rootElementPath, Nullable`1 dateParseHandlingOverride)
at ShopifySharp.ShopifyService.ExecuteRequestCoreAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, Dictionary`2 headers, String rootElement, Nullable`1 graphqlQueryCost, Nullable`1 dateParseHandlingOverride)
at ShopifySharp.ShopifyService.ExecuteRequestAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, String rootElement, Dictionary`2 headers)
at ShopifySharp.GiftCardService.CreateAsync(GiftCard giftCard, CancellationToken cancellationToken)
at Flourish.PaymentProcessing.ShopifyFlourishGiftCardService.ActivateGiftCardAsync(String code, Int64 amount)
Something about Parsing Dates?? Not sure. Any help would be much appreciated!