Erro no Checkout com API Tax Services

Boa tarde!

Desenvolvi uma API para cálculo dos impostos (tax services) e configurei a mesma
como endpoint a ser consumida no checkout de nossa loja VTEX, usando como referência o guia de integração de Tax Services.

Quando tento inserir um item no carrinho está ocorrendo erro:

Desculpe, ocorreu um erro durante o processamento da sua chamada.
ID da Operação: eee5f373-8320-40fc-9ef4-43163db92011

A API está sendo chamada, a comunicação entre a plataforma VTEX e nosso backend
está ocorrendo, recebo o payload completo da transação, o mesmo é interpretado
e a API responde conforme documentação (exemplo abaixo).

Entretanto não consigo entender o motivo do erro. Alguém teria alguma pista para me ajudar?

Resposta da API:

{
  "itemTaxResponse": [
    {
      "id": "0",
      "taxes": [
        {
          "name": "IPI",
          "description": "",
          "value": 18.77
        }
      ]
    }
  ],
  "hooks": [
  ]
}

Erro da Operação (Log da VTEX)

ExtraData:
 
ErrorMessage: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1
[Vtex.Commerce.Checkout.Services.TaxHub.Response.ItemTaxResponse]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path 'hooks', line 1, position 9.
ErrorStack: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Vtex.Commerce.Checkout.Services.TaxHub.Response.ItemTaxResponse]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path 'hooks', line 1, position 9.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)

Você está setando o Content-Type da resposta da API como application/vnd.vtex.checkout.minicart.v1+json?

Screen Shot 2021-09-23 at 16.53.25

Prezado George!
Muitíssimo obrigado pela sua ajuda.
Apesar de eu ter adicionado o respectivo content-type no retorno da api,
nosso proxy reverso estava mudando o content-type para “application/json” e eu
não tinha sequer percebido.
Salvou meu dia .

Abs,

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.